Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +26 -22
Dockerfile
CHANGED
@@ -1,23 +1,27 @@
|
|
1 |
-
#
|
2 |
-
FROM python:3.
|
3 |
-
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
#
|
|
|
|
|
|
|
|
|
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"]
|