# broke as one container. Built from this checkout, so it runs exactly the commit you have here.
# Use docker/docker-compose.yml to run it with its own database and sign-in (see docker/README.md).
#
# NEXT_PUBLIC_* values are built into the browser code, so they are build args. Change them and you rebuild.

FROM node:22-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --no-audit --no-fund
COPY . .
ARG NEXT_PUBLIC_SUPABASE_URL
ARG NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL \
    NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=$NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY \
    NEXT_TELEMETRY_DISABLED=1
RUN npm run build

FROM node:22-alpine
WORKDIR /app
ENV NODE_ENV=production NEXT_TELEMETRY_DISABLED=1 PORT=3000
COPY --from=build --chown=node:node /app /app
USER node
EXPOSE 3000
# next start directly, not scripts/start.mjs: that one git-pulls on every start and listens on 127.0.0.1 only.
# Database changes in supabase/migrations still apply on start (src/instrumentation.ts) through SUPABASE_DB_URL.
CMD ["node_modules/.bin/next", "start", "-H", "0.0.0.0", "-p", "3000"]
