akhaliq HF Staff commited on
Commit
4e627ae
·
verified ·
1 Parent(s): e722741

Upload Dockerfile (Alternative - More Robust) with huggingface_hub

Browse files
Dockerfile (Alternative - More Robust) ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:18-slim
2
+
3
+ # Create app directory and set up user
4
+ RUN mkdir -p /home/user && \
5
+ addgroup --system --gid 1001 nodejs || true && \
6
+ adduser --system --uid 1000 --gid 1001 --no-create-home --home /home/user user || true
7
+
8
+ USER user
9
+ ENV HOME=/home/user \
10
+ PATH=/home/user/.local/bin:$PATH
11
+
12
+ # Set working directory
13
+ WORKDIR $HOME/app
14
+
15
+ # Copy package files with proper ownership
16
+ COPY --chown=user package*.json ./
17
+
18
+ # Install dependencies
19
+ RUN npm install
20
+
21
+ # Copy rest of the application with proper ownership
22
+ COPY --chown=user . .
23
+
24
+ # Build the Next.js app
25
+ RUN npm run build
26
+
27
+ # Expose port 7860
28
+ EXPOSE 7860
29
+
30
+ # Start the application on port 7860
31
+ CMD ["npm", "start", "--", "-p", "7860"]
32
+
33
+ If those still don't work, here's a fallback approach that doesn't create a specific user: