Spaces:
Running
Running
File size: 744 Bytes
8b3ddc0 01c681c 8b3ddc0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# Use the official Node.js runtime as the base image
FROM node:18-alpine
# Set the working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json (if available)
COPY package*.json ./
# Install dependencies - use npm install if package-lock.json doesn't exist
RUN npm install --omit=dev
# Copy the rest of the application code
COPY . .
# Create a non-root user to run the app
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
# Change ownership of the app directory to the nodejs user
RUN chown -R nextjs:nodejs /app
USER nextjs
# Expose the port the app runs on
EXPOSE 7860
# Define environment variable for the port (HF Spaces uses 7860)
ENV PORT=7860
# Start the application
CMD ["npm", "start"] |