31 lines
592 B
Docker
31 lines
592 B
Docker
# Stage 1: Build & install production dependencies
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy dependency configs
|
|
COPY package.json ./
|
|
|
|
# Install only production dependencies
|
|
RUN npm install --only=production
|
|
|
|
# Stage 2: Final runtime container
|
|
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy built node_modules
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY package.json ./
|
|
COPY cmd/ ./cmd/
|
|
COPY internal/ ./internal/
|
|
|
|
# Use the built-in non-root user 'node' (UID 1000)
|
|
USER node
|
|
|
|
# Expose backend service port
|
|
EXPOSE 47880
|
|
|
|
# Execute server
|
|
CMD ["node", "cmd/server/main.js"]
|