# Use an official Node.js runtime as a parent image FROM node:20-alpine # Set the working directory inside the container WORKDIR /app # Copy package files and set ownership COPY --chown=node:node package*.json ./ # Install dependencies RUN npm install --omit=dev # Copy the rest of the app's source code with correct ownership COPY --chown=node:node . . # Use a non-root user for better security USER node # Expose the application port EXPOSE 3000 # Set environment variables (optional) ENV NODE_ENV=production # Start the application CMD ["npm", "run", "start"]