YADUUG commited on
Commit
0f2d277
·
1 Parent(s): 4e06012

refactor: use existing base image user `pwuser` (UID 1000) instead of creating a new user in the Dockerfile.

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -8
Dockerfile CHANGED
@@ -5,8 +5,10 @@ FROM mcr.microsoft.com/playwright/python:v1.41.0-jammy
5
  # Set non-interactive mode for apt
6
  ENV DEBIAN_FRONTEND=noninteractive
7
 
8
- # Create a user to run the application (HF Spaces uses user 1000)
9
- RUN useradd -m -u 1000 user
 
 
10
 
11
  # Set working directory
12
  WORKDIR /app
@@ -35,24 +37,24 @@ RUN playwright install chromium
35
  # Copy application code
36
  COPY . .
37
 
38
- # Adjust permissions for the user
39
- RUN chown -R user:user /app
40
 
41
  # Create necessary directories for the app (data, cache) and ensure permission
42
  # HF Spaces likes /data for persistent storage if configured, but we map it in code.
43
  # Here we just make sure our app directories are writable
44
  RUN mkdir -p /app/data /app/memory /tmp/cache /tmp/hf && \
45
- chown -R user:user /app/data /app/memory /tmp/cache /tmp/hf
46
 
47
- # Switch to the non-root user
48
- USER user
49
 
50
  # Expose the port
51
  EXPOSE 7860
52
 
53
  # Define environment variables
54
  ENV PYTHONUNBUFFERED=1
55
- ENV HOME=/home/user
56
 
57
  # Start the application
58
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
5
  # Set non-interactive mode for apt
6
  ENV DEBIAN_FRONTEND=noninteractive
7
 
8
+ # The base image already has a user 'pwuser' with UID 1000.
9
+ # We will use this user instead of creating a new one to avoid conflicts.
10
+ # HF Spaces expects the app to run as user 1000.
11
+
12
 
13
  # Set working directory
14
  WORKDIR /app
 
37
  # Copy application code
38
  COPY . .
39
 
40
+ # Adjust permissions for the user (using UID 1000)
41
+ RUN chown -R 1000:1000 /app
42
 
43
  # Create necessary directories for the app (data, cache) and ensure permission
44
  # HF Spaces likes /data for persistent storage if configured, but we map it in code.
45
  # Here we just make sure our app directories are writable
46
  RUN mkdir -p /app/data /app/memory /tmp/cache /tmp/hf && \
47
+ chown -R 1000:1000 /app/data /app/memory /tmp/cache /tmp/hf
48
 
49
+ # Switch to the non-root user (UID 1000)
50
+ USER 1000
51
 
52
  # Expose the port
53
  EXPOSE 7860
54
 
55
  # Define environment variables
56
  ENV PYTHONUNBUFFERED=1
57
+ ENV HOME=/home/pwuser
58
 
59
  # Start the application
60
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]