jurmy24 commited on
Commit
b807b54
·
1 Parent(s): 89a68ce

fix: don't try to create a new user

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -16
Dockerfile CHANGED
@@ -1,29 +1,29 @@
1
  FROM node:18-alpine
2
 
3
- # Create user with UID 1000 as recommended by Hugging Face Spaces
4
- RUN adduser -D -u 1000 user || echo "User 1000 likely already exists, continuing..."
5
-
6
- # Set up environment variables
7
- ENV HOME=/home/user \
8
- PATH=/home/user/.local/bin:$PATH
9
-
10
- # Create and set up app directory with proper permissions
11
- WORKDIR $HOME/app
12
  RUN mkdir -p $HOME/app && \
13
- chown -R user:user $HOME/app && \
14
  chmod -R 755 $HOME/app # Set initial permissions
 
15
 
16
- # Switch to the user
17
- USER user
18
 
19
- # Copy package files
20
- COPY --chown=user viewer/package*.json ./
21
 
22
  # Install dependencies
23
  RUN npm install
24
 
25
- # Copy the entire viewer directory
26
- COPY --chown=user viewer/ .
27
 
28
  # Build the application
29
  RUN npm run build
 
1
  FROM node:18-alpine
2
 
3
+ # Use the existing node user (usually UID 1000)
4
+ # Set up environment variables for the node user
5
+ ENV HOME=/home/node \
6
+ PATH=/home/node/.local/bin:$PATH
7
+
8
+ # Create and set up app directory owned by node user
9
+ # Go to user's home directory first to ensure it exists
10
+ WORKDIR $HOME
 
11
  RUN mkdir -p $HOME/app && \
12
+ chown -R node:node $HOME/app && \
13
  chmod -R 755 $HOME/app # Set initial permissions
14
+ WORKDIR $HOME/app # Set the final working directory
15
 
16
+ # Switch to the node user
17
+ USER node
18
 
19
+ # Copy package files (owned by node)
20
+ COPY --chown=node:node viewer/package*.json ./
21
 
22
  # Install dependencies
23
  RUN npm install
24
 
25
+ # Copy the entire viewer directory (owned by node)
26
+ COPY --chown=node:node viewer/ .
27
 
28
  # Build the application
29
  RUN npm run build