# build stage
FROM node:slim AS build-stage
# Set environment variables for non-interactive npm installs
ENV NPM_CONFIG_LOGLEVEL=warn
ENV CI true
WORKDIR /app
# Copy the entire project and install dependencies then build
COPY . .
RUN npm install -g pnpm && pnpm i --frozen-lockfile
RUN pnpm build
# production stage
FROM nginx:stable-alpine3.23-perl AS production-stage
# Copy built assets from build stage to nginx html folder
COPY --from=build-stage /app/dist /usr/share/nginx/html
# Copy nginx config (must exist in repo)
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port 80
EXPOSE 80
# Run nginx in the foreground
CMD ["nginx", "-g", "daemon off;"]