- Implement multi-stage build to reduce final image size - Install only production dependencies with npm ci --only=production - Clean npm cache to reduce image size - Improve layer caching by copying package files before application code - Update package version from 1.0.0 to 1.0.1
23 lines
372 B
Docker
23 lines
372 B
Docker
FROM node:24-slim AS builder
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
# Copy dependency files first
|
|
COPY package*.json ./
|
|
|
|
# Install production dependencies only
|
|
RUN npm ci --only=production && npm cache clean --force
|
|
|
|
FROM node:24-slim
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
COPY --from=builder /usr/src/app/node_modules ./node_modules
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
EXPOSE 3000
|
|
|
|
CMD ["npm", "start"]
|