This commit is contained in:
2026-03-18 16:02:25 +07:00
parent 6b69d4f64c
commit fa98e42349
2 changed files with 28 additions and 5 deletions

View File

@@ -3,26 +3,34 @@ FROM node:18-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
RUN npm install
# Install dependencies with production flag
RUN npm ci --only=production && npm ci
# Copy source code
COPY . .
RUN npm run build 2>/dev/null || true
# Build production bundle with optimizations
RUN NODE_ENV=production npm run build 2>/dev/null || true
# Production stage
# Production stage - optimize serving
FROM node:18-alpine
WORKDIR /app
# Install serve with gzip compression support
RUN npm install -g serve
# Copy built app from builder
COPY --from=builder /app/build ./build
EXPOSE 3000
# Health check
HEALTHCHECK --interval=10s --timeout=5s --retries=5 \
CMD curl -f http://localhost:3000 || exit 1
CMD wget --quiet --tries=1 --spider http://localhost:3000/ || exit 1
CMD ["serve", "-s", "build", "-l", "3000"]
# Start server with compression and caching headers
CMD ["serve", "-s", "build", "-l", "3000", "--gzip"]