# Use node alpine docker image
FROM docker.io/node:22-alpine

ARG PACKAGE=flood
ARG VERSION=latest

# Get specified version from npm
RUN npm i -g "${PACKAGE}"@"${VERSION}" &&\
    node --version &&\
    npm ls --global &&\
    npm cache clean --force

# Install runtime dependencies
RUN apk --no-cache add \
    mediainfo \
    tini \
    coreutils

# Create "download" user
RUN adduser -h /home/download -s /sbin/nologin --disabled-password download

# Run as "download" user
USER download

# Expose port 3000
EXPOSE 3000

# Flood
ENV FLOOD_OPTION_HOST="0.0.0.0"
ENTRYPOINT ["/sbin/tini", "--", "flood"]
