FROM node:18-slim
WORKDIR /app
# Copy package files and install dependencies
COPY package*.json ./
RUN npm install
# Copy source code and build
COPY . .
RUN npm run build
# Set execution permissions
RUN chmod +x build/index.js
# Clean up dev dependencies
RUN npm prune --production
# Run as non-root user for security
USER node
# Set environment variables
ENV NODE_ENV=production
# Command to run the server
ENTRYPOINT ["node", "build/index.js"]