2025-01-23 08:57:01 +00:00
|
|
|
# Build stage
|
|
|
|
FROM node:20-alpine AS builder
|
|
|
|
|
|
|
|
# Set working directory
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# Install dependencies first (for better caching)
|
|
|
|
COPY package.json pnpm-lock.yaml ./
|
|
|
|
RUN corepack enable pnpm && pnpm install --frozen-lockfile
|
|
|
|
|
|
|
|
# Copy source code
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
# Build the application
|
|
|
|
RUN pnpm build
|
|
|
|
|
|
|
|
# Production stage
|
|
|
|
FROM nginx:alpine
|
|
|
|
|
|
|
|
# Copy custom nginx config if needed
|
|
|
|
# COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
|
|
|
|
# Copy built assets from builder stage
|
|
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
|
|
|
|
# Add healthcheck
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s \
|
|
|
|
CMD wget --quiet --tries=1 --spider http://localhost:80/ || exit 1
|
|
|
|
|
|
|
|
# Expose port
|
|
|
|
EXPOSE 80
|
|
|
|
|
|
|
|
# Start nginx
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|