nonamelife commited on
Commit
cb2502d
·
verified ·
1 Parent(s): acd4e50

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -22
Dockerfile CHANGED
@@ -1,23 +1,27 @@
1
- # Use a lightweight Python base image
2
- FROM python:3.10-slim-buster
3
-
4
- # Set the working directory in the container
5
- WORKDIR /app
6
-
7
- # Copy requirements.txt and install Python dependencies
8
- COPY requirements.txt .
9
- RUN pip install --no-cache-dir -r requirements.txt
10
-
11
- # Copy the rest of your application code
12
- COPY . .
13
-
14
- # Ensure the static/uploads directory exists (if not created by your app)
15
- RUN mkdir -p static/uploads
16
-
17
- # Expose the port that Flask will run on (Hugging Face Spaces uses PORT env var)
18
- EXPOSE 7860
19
-
20
- # Command to run your Flask application
21
- # Hugging Face Spaces will set the PORT environment variable.
22
- # Your app.py is already set up to use it (os.environ.get('PORT', 7860)).
 
 
 
 
23
  CMD ["python", "app.py"]
 
1
+ # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker# you will also find guides on how best to write your Dockerfile
2
+ FROM python:3.9 # Keep this as your Python version
3
+
4
+ # Create a user with UID 1000 and set as default user
5
+ RUN useradd -m -u 1000 user
6
+ USER user
7
+
8
+ # Set environment variables for the user
9
+ ENV PATH="/home/user/.local/bin:$PATH"
10
+ WORKDIR /app
11
+
12
+ # Set HF_HOME environment variable to a writable directory
13
+ # This tells huggingface_hub where to store its cache and downloaded models
14
+ ENV HF_HOME="/app/.cache/huggingface"
15
+
16
+ # Copy requirements.txt first to leverage Docker cache
17
+ COPY --chown=user ./requirements.txt requirements.txt
18
+
19
+ # Install Python dependencies
20
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
21
+
22
+ # Copy the rest of your application code
23
+ COPY --chown=user . /app
24
+
25
+ # Command to run your Flask application
26
+ # It will listen on the PORT environment variable provided by Hugging Face Spaces
27
  CMD ["python", "app.py"]