krinya commited on
Commit
112d492
·
1 Parent(s): b18de1a

Fix Docker permission issues for Hugging Face Spaces

Browse files

- Create non-root user 'app' to avoid permission issues
- Set UV_CACHE_DIR to writable location in app directory
- Change ownership of app directory to non-root user
- Add .uv-cache to .dockerignore for cleaner builds

Files changed (2) hide show
  1. .dockerignore +3 -0
  2. Dockerfile +11 -1
.dockerignore CHANGED
@@ -20,6 +20,9 @@ coverage.xml
20
  .venv
21
  .venv*/
22
 
 
 
 
23
  # IDE
24
  .vscode
25
  .idea
 
20
  .venv
21
  .venv*/
22
 
23
+ # UV cache
24
+ .uv-cache
25
+
26
  # IDE
27
  .vscode
28
  .idea
Dockerfile CHANGED
@@ -1,5 +1,8 @@
1
  FROM python:3.12-slim
2
 
 
 
 
3
  # Set working directory
4
  WORKDIR /app
5
 
@@ -13,8 +16,15 @@ RUN apt-get update && apt-get install -y \
13
  # Install uv
14
  RUN pip install uv
15
 
16
- # Copy project files
17
  COPY . .
 
 
 
 
 
 
 
18
 
19
  # Install dependencies using uv
20
  RUN uv sync --frozen
 
1
  FROM python:3.12-slim
2
 
3
+ # Create a non-root user
4
+ RUN useradd --create-home --shell /bin/bash app
5
+
6
  # Set working directory
7
  WORKDIR /app
8
 
 
16
  # Install uv
17
  RUN pip install uv
18
 
19
+ # Copy project files and change ownership
20
  COPY . .
21
+ RUN chown -R app:app /app
22
+
23
+ # Switch to non-root user
24
+ USER app
25
+
26
+ # Set uv cache directory to a writable location
27
+ ENV UV_CACHE_DIR=/app/.uv-cache
28
 
29
  # Install dependencies using uv
30
  RUN uv sync --frozen