# for deploying a Next.js application in a Docker container # Use Node 22 as the base image FROM node:22-alpine # Set the working directory inside the container WORKDIR /app # Copy package.json and package-lock.json COPY package*.json ./ # Install dependencies RUN npm install # Copy the rest of the application code COPY . . # Expose the port your app runs on EXPOSE 7860 # --- FIX IS HERE --- # Build the application. This runs during the `docker build` command. RUN npm run build # Change ownership of /app to the node user # Do this *after* all root operations (like npm install/build) are done RUN chown -R node:node /app # Switch to a non-root user for better security USER node # Command to run the application when the container starts CMD ["npm", "run", "start"]