# Build Stage
FROM node:20-alpine AS build
WORKDIR /app
# Copy package files and install dependencies
COPY package*.json ./
RUN npm ci
# Copy the rest of the app and build it
COPY . .
RUN npm run build
# Production Stage - Simple HTTP server
FROM node:20-alpine
# Install serve package globally for serving static files
RUN npm install -g serve
# Copy the built app from the build stage
COPY --from=build /app/dist ./dist
# Copy the env.sh script for runtime configuration
COPY env.sh /app/env.sh
RUN chmod +x /app/env.sh
# Expose port 3000
EXPOSE 3000
# Use env.sh to generate runtime config, then start serve
CMD ["/app/env.sh", "serve", "-s", "dist", "-l", "3000"]