FROM node:20-alpine

# gettext provides envsubst for settings.json template rendering
RUN apk add --no-cache gettext bash

WORKDIR /app

COPY package*.json ./
RUN npm install --omit=dev

COPY . .

# Compile SCSS → CSS (prestart.js also connects to MongoDB which isn't available at build time)
RUN node ./scripts/compile_css.js

RUN chmod +x /app/docker/entrypoint.sh && mkdir -p /app/tmp

EXPOSE 3001

ENTRYPOINT ["/app/docker/entrypoint.sh"]
CMD ["web"]
