Spaces:
Sleeping
Sleeping
Sgridda
commited on
Commit
·
fe2db02
1
Parent(s):
ead1873
Fix cache permissions using chmod
Browse files- Dockerfile +7 -9
Dockerfile
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
-
|
| 2 |
# Use the official Python 3.9 slim image
|
| 3 |
FROM python:3.9-slim
|
| 4 |
|
| 5 |
# Set the working directory inside the container
|
| 6 |
WORKDIR /code
|
| 7 |
|
| 8 |
-
# Create a directory for the model cache
|
| 9 |
-
#
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
# Set the HF_HOME environment variable to point to our new cache directory.
|
| 13 |
ENV HF_HOME /code/cache
|
|
@@ -19,8 +19,6 @@ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
| 19 |
# Copy the application code
|
| 20 |
COPY ./main.py /code/main.py
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
# Command to run the FastAPI server
|
| 26 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|
|
| 1 |
# Use the official Python 3.9 slim image
|
| 2 |
FROM python:3.9-slim
|
| 3 |
|
| 4 |
# Set the working directory inside the container
|
| 5 |
WORKDIR /code
|
| 6 |
|
| 7 |
+
# Create a directory for the model cache and make it world-writable.
|
| 8 |
+
# This ensures that the non-root user running the app can write to it,
|
| 9 |
+
# without needing to know the user's name during the build.
|
| 10 |
+
RUN mkdir /code/cache && chmod 777 /code/cache
|
| 11 |
|
| 12 |
# Set the HF_HOME environment variable to point to our new cache directory.
|
| 13 |
ENV HF_HOME /code/cache
|
|
|
|
| 19 |
# Copy the application code
|
| 20 |
COPY ./main.py /code/main.py
|
| 21 |
|
| 22 |
+
# Command to run the FastAPI server.
|
| 23 |
+
# The Hugging Face platform will run this command as a non-root user.
|
| 24 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|