admin08077 commited on
Commit
546ff54
·
verified ·
1 Parent(s): 7b58e87

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -15
Dockerfile CHANGED
@@ -1,27 +1,33 @@
1
- FROM node:18
 
2
 
3
- WORKDIR /app
 
4
 
5
- # Install unzip and any needed utilities
6
- RUN apt-get update && apt-get install -y unzip
 
7
 
8
- # Copy your zip file
9
- COPY Archive.zip /app/
10
 
11
- # Unzip and remove archive
12
- RUN unzip Archive.zip && rm Archive.zip
13
 
14
- # Make sure the app directory is owned by node user (safer than root)
15
- RUN chown -R node:node /app
16
 
17
- # Switch to non-root user for better security and permission handling
18
- USER node
19
 
20
- # Install dependencies as node user
 
 
 
21
  RUN npm install
22
 
23
- # Expose port (adjust if needed)
24
  EXPOSE 3000
25
 
26
  # Start the app
27
- CMD ["npm", "run", "dev"]
 
1
+ # Use an official Node.js image (adjust version as needed)
2
+ FROM node:20
3
 
4
+ # Create a non-root user with UID 1000 (matches HF Spaces)
5
+ RUN useradd -m -u 1000 user
6
 
7
+ # Set environment variables for the user
8
+ ENV HOME=/home/user \
9
+ PATH=/home/user/.local/bin:$PATH
10
 
11
+ # Set working directory inside the user's home
12
+ WORKDIR $HOME/app
13
 
14
+ # Install unzip and any other utilities
15
+ RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*
16
 
17
+ # Copy zip file with correct ownership
18
+ COPY --chown=user:user Archive.zip .
19
 
20
+ # Unzip as root (so unzip is available) then change ownership in one step
21
+ RUN unzip Archive.zip && rm Archive.zip && chown -R user:user $HOME/app
22
 
23
+ # Switch to the non-root user
24
+ USER user
25
+
26
+ # Install dependencies
27
  RUN npm install
28
 
29
+ # Expose the app port (adjust if needed)
30
  EXPOSE 3000
31
 
32
  # Start the app
33
+ CMD ["npm", "start"]