Owadokun Tosin Tobi commited on
Commit
0d28276
·
unverified ·
1 Parent(s): 6397cdc

I included a chown fix

Browse files

Changes: Included the critical chown fix to prevent Permission Errors with FastHTML session files.

Files changed (1) hide show
  1. Dockerfile +18 -14
Dockerfile CHANGED
@@ -1,28 +1,32 @@
1
- # 1. Base Image (Lightweight Python)
2
  FROM python:3.11-slim
3
 
4
- # 2. System Setup
5
- WORKDIR /app
6
- ENV PYTHONUNBUFFERED=1 \
7
- PYTHONDONTWRITEBYTECODE=1 \
8
- PYTHONPATH=/app
9
-
10
- # 3. Install System Dependencies (Minimal build tools)
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
  build-essential \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
- # 4. Install Python Dependencies
 
 
 
 
 
 
16
  COPY requirements.txt .
17
  RUN pip install --no-cache-dir -r requirements.txt
18
 
19
- # 5. Copy Application Code
20
- COPY . .
 
21
 
22
- # 6. Create Non-Root User (Security Best Practice)
23
- RUN useradd -m -u 1000 user
 
 
24
  USER user
25
  ENV PATH="/home/user/.local/bin:$PATH"
 
26
 
27
- # 7. Run the Entry Point (Port 7860 for Hugging Face)
28
  CMD ["python", "run.py"]
 
1
+ # 1. Base Image
2
  FROM python:3.11-slim
3
 
4
+ # 2. System Setup (Minimal build dependencies)
 
 
 
 
 
 
5
  RUN apt-get update && apt-get install -y --no-install-recommends \
6
  build-essential \
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
+ # 3. Create Non-Root User (Security Best Practice)
10
+ RUN useradd -m -u 1000 user
11
+
12
+ # 4. Set Workspace
13
+ WORKDIR /app
14
+
15
+ # 5. Install Dependencies
16
  COPY requirements.txt .
17
  RUN pip install --no-cache-dir -r requirements.txt
18
 
19
+ # 6. Copy Code & Enforce Ownership
20
+ # We use --chown to ensure files belong to the user
21
+ COPY --chown=user . .
22
 
23
+ # 7. CRITICAL FIX: Ensure the user owns the directory (for .sesskey creation)
24
+ RUN chown -R user:user /app
25
+
26
+ # 8. Switch to User & Set Path
27
  USER user
28
  ENV PATH="/home/user/.local/bin:$PATH"
29
+ ENV PYTHONPATH=/app
30
 
31
+ # 9. Run Entry Point
32
  CMD ["python", "run.py"]