37 lines
714 B
Docker
37 lines
714 B
Docker
# Build stage
|
|
FROM node:18-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm install
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build production bundle with optimizations
|
|
RUN NODE_ENV=production npm run build
|
|
|
|
# Production stage - minimal footprint
|
|
FROM node:18-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Install serve for static file serving
|
|
RUN npm install -g serve@14
|
|
|
|
# Copy built app from builder
|
|
COPY --from=builder /app/build ./build
|
|
|
|
EXPOSE 3000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=10s --timeout=5s --retries=5 \
|
|
CMD wget --quiet --tries=1 --spider http://localhost:3000/ || exit 1
|
|
|
|
# Start server with gzip compression
|
|
CMD ["serve", "-s", "build", "-l", "3000", "--gzip"]
|