FROM node:20-slim

WORKDIR /usr/src/app

# Install dependencies from the lockfile for reproducible builds.
COPY package*.json ./
RUN npm ci --omit=dev

# Bundle app source. `.dockerignore` deliberately excludes `config/`, `.env`,
# `uploads/`, and other runtime state so the image is stateless.
COPY . .

# Env vars are supplied at runtime, either via `docker run --env-file .env`,
# `-e KEY=VALUE`, or compose/K8s. `config/` and `uploads/` should be mounted
# as volumes so tokens, jobs, and uploaded CSVs persist across restarts.
#
# The listening port is controlled by the SERVER_PORT env var; EXPOSE below
# is informational and should be aligned with whatever SERVER_PORT is set to
# at deploy time.
ENV NODE_ENV=production
EXPOSE 1450

CMD ["node", "index.js"]
