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 # Add to PATH for easier usage ENV PATH="/app/dist:${PATH}" CMD ["node", "dist/index.js"]