# 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
# Expose port 3000
EXPOSE 3000
# Serve the static files
CMD ["serve", "-s", "dist", "-l", "3000"]