FROM node:18-alpine WORKDIR /app # Copy package files COPY package*.json ./ # Install all dependencies (including dev deps for building) RUN npm install # Copy source code COPY . . # Build TypeScript RUN npm run build # Remove dev dependencies to reduce image size RUN npm prune --production # Create non-root user 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 EXPOSE 3001 CMD ["npm", "start"]