Dockerfile multistage

This commit is contained in:
albert
2025-07-28 13:09:36 +02:00
parent 90c6c8392f
commit fa13aaf069
2 changed files with 50 additions and 13 deletions

View File

@ -1,21 +1,15 @@
# Use Node.js 24 slim image
FROM node:24-slim
# Set working directory
FROM node:24-slim AS builder
WORKDIR /app
# Install dependencies first (for better caching)
COPY package*.json ./
RUN npm install
# Copy the rest of the code
COPY . .
# Build project (for production)
RUN npm run build
# Expose port if needed (optional, e.g., 3000)
FROM node:24-slim AS production
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY --from=builder /app/dist ./dist
EXPOSE 3000
# Run app in production mode
CMD ["node", "dist/index.js"]