Spaces:
Sleeping
Sleeping
| # Use the official Node.js image as a base | |
| FROM node:20 | |
| # Set the working directory | |
| WORKDIR /app | |
| # Copy package.json and package-lock.json into the container | |
| COPY package.json package-lock.json ./ | |
| # Install dependencies using npm (use --legacy-peer-deps if you face dependency issues) | |
| RUN npm install --legacy-peer-deps --unsafe-perm=true | |
| # Create a non-root user and set permissions | |
| RUN useradd -m appuser | |
| # Ensure the /app directory is owned by the non-root user | |
| RUN chown -R appuser /app | |
| # Switch to the non-root user | |
| USER appuser | |
| # Copy the rest of your application code into the container | |
| COPY . . | |
| # Build the Next.js app | |
| RUN npm run build | |
| # Expose the port the app will run on | |
| EXPOSE 3000 | |
| # Start the Next.js app | |
| CMD ["npm", "start"] | |