36 lines
644 B
Docker
36 lines
644 B
Docker
# --- Stage 1: Build ---
|
|
FROM node:18-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
|
|
# Copy source and compile
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# --- Stage 2: Production ---
|
|
FROM node:18-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy only production dependencies
|
|
COPY package*.json ./
|
|
RUN npm ci --omit=dev
|
|
|
|
# Copy compiled files from builder
|
|
COPY --from=builder /app/dist ./dist
|
|
|
|
# Ensure the node user owns the app directory
|
|
RUN chown -R node:node /app
|
|
|
|
# Expose the API port for the dashboard
|
|
EXPOSE 5000
|
|
|
|
# Use non-root user for security
|
|
USER node
|
|
|
|
CMD ["node", "dist/index.js"]
|