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