# Use Node.js 20 Alpine for smaller image size
FROM node:20-alpine
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install all dependencies (including dev dependencies for building)
RUN npm ci
# Copy source code
COPY . .
# Build the TypeScript code
RUN npm run build
# Remove dev dependencies to reduce image size
RUN npm prune --production
# Expose the port
EXPOSE 8080
# Create non-root user for security
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nodejs -u 1001
# Change ownership of the app directory
RUN chown -R nodejs:nodejs /app
USER nodejs
# Start the application
CMD ["npm", "start"]