# ABOUTME: Multi-stage Docker build for Express API
# ABOUTME: Creates minimal production image with compiled TypeScript

# Build stage
FROM node:20-alpine AS builder

WORKDIR /app

COPY package.json ./
RUN {{installCommand}}

COPY tsconfig.json ./
COPY *.ts ./
RUN {{runScriptPrefix}} build

# Production stage
FROM node:20-alpine

WORKDIR /app

# Copy package files and install production dependencies only
COPY package.json ./
RUN {{installProdCommand}}

# Copy compiled JavaScript from builder
COPY --from=builder /app/dist ./dist

# Run as non-root user for security
USER node

EXPOSE 80

CMD ["node", "dist/index.js"]
