Update Dockerfile to multi-stage build that compiles TypeScript

This commit is contained in:
oonyeje 2026-07-07 04:17:35 +00:00
parent 563c2a73dd
commit 2e21d1a407

View File

@ -1,12 +1,25 @@
# ---- Build stage ----------------------------------------------------------
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json tsconfig.json ./
RUN npm install --no-audit --no-fund
COPY src/ ./src/
RUN npm run build
# ---- Runtime stage --------------------------------------------------------
FROM node:20-alpine FROM node:20-alpine
WORKDIR /app WORKDIR /app
# Install production dependencies # Install only production dependencies
COPY package*.json ./ COPY package*.json ./
RUN npm install --omit=dev && npm cache clean --force RUN npm install --omit=dev --no-audit --no-fund && npm cache clean --force
# Copy application code # Copy compiled output and entry point
COPY --from=builder /app/dist ./dist
COPY server.js ./ COPY server.js ./
# Run as non-root user for security # Run as non-root user for security