File: //srv/rmgun_admin/admin-next/dockers/prod/Dockerfile.express
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY express/package*.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY express/ .
# Build TypeScript
RUN npm run build
# Production stage
FROM node:20-alpine AS runner
WORKDIR /app
# Install curl for healthcheck
RUN apk add --no-cache curl
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S express -u 1001
# Copy package files and install production dependencies only
COPY express/package*.json ./
RUN npm ci --only=production
# Copy built application
COPY --from=builder /app/dist ./dist
# Change ownership to non-root user
RUN chown -R express:nodejs /app
USER express
EXPOSE 4000
ENV NODE_ENV=production
ENV PORT=4000
CMD ["node", "dist/index.js"]