grixelle commited on
Commit
5cbd85c
·
verified ·
1 Parent(s): b9974f1

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -11
Dockerfile CHANGED
@@ -1,23 +1,31 @@
1
- # Use a stable base image
2
  FROM python:3.11-slim
3
 
4
- # Set up a non-root user (Hugging Face security requirement)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  RUN useradd -m -u 1000 user
6
  USER user
7
  ENV HOME=/home/user \
8
  PATH=/home/user/.local/bin:$PATH
9
 
10
- WORKDIR $HOME/app
11
-
12
- # Install dependencies
13
- COPY --chown=user requirements.txt .
14
- RUN pip install --no-cache-dir -r requirements.txt
15
-
16
- # Copy application files
17
  COPY --chown=user . .
18
 
19
- # Hugging Face Spaces default to port 7860
20
  EXPOSE 7860
21
 
22
- # Run the app, binding to all network interfaces
23
  CMD ["python", "app.py"]
 
1
+ # Use a stable Python 3.11 base image
2
  FROM python:3.11-slim
3
 
4
+ # Install system dependencies as root
5
+ RUN apt-get update && apt-get install -y \
6
+ build-essential \
7
+ && rm -rf /var/lib/apt/lists/*
8
+
9
+ # Set the working directory
10
+ WORKDIR /app
11
+
12
+ # Copy requirements first to leverage Docker cache
13
+ COPY requirements.txt .
14
+
15
+ # Install Python packages as root into the system path
16
+ RUN pip install --no-cache-dir -r requirements.txt
17
+
18
+ # Create a non-root user for security (HF requirement)
19
  RUN useradd -m -u 1000 user
20
  USER user
21
  ENV HOME=/home/user \
22
  PATH=/home/user/.local/bin:$PATH
23
 
24
+ # Copy the rest of the app files as the new user
 
 
 
 
 
 
25
  COPY --chown=user . .
26
 
27
+ # Expose the mandatory Gradio port
28
  EXPOSE 7860
29
 
30
+ # Run the app
31
  CMD ["python", "app.py"]