Spaces:
Sleeping
Sleeping
Sgridda
commited on
Commit
·
ead1873
1
Parent(s):
2f0ed7b
Fix cache ownership permissions
Browse files- Dockerfile +13 -11
Dockerfile
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
|
|
| 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
|
| 8 |
-
#
|
| 9 |
-
RUN mkdir /code/cache
|
|
|
|
|
|
|
| 10 |
ENV HF_HOME /code/cache
|
| 11 |
|
| 12 |
-
# Copy the requirements file
|
| 13 |
COPY ./requirements.txt /code/requirements.txt
|
| 14 |
-
|
| 15 |
-
# Install the Python dependencies
|
| 16 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 17 |
|
| 18 |
-
# Copy the
|
| 19 |
COPY ./main.py /code/main.py
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
| 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, and change its ownership to the non-root user.
|
| 9 |
+
# The user is 'user' in the standard Hugging Face environment.
|
| 10 |
+
RUN mkdir /code/cache && chown -R user:user /code/cache
|
| 11 |
+
|
| 12 |
+
# Set the HF_HOME environment variable to point to our new cache directory.
|
| 13 |
ENV HF_HOME /code/cache
|
| 14 |
|
| 15 |
+
# Copy the requirements file and install dependencies
|
| 16 |
COPY ./requirements.txt /code/requirements.txt
|
|
|
|
|
|
|
| 17 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 18 |
|
| 19 |
+
# Copy the application code
|
| 20 |
COPY ./main.py /code/main.py
|
| 21 |
|
| 22 |
+
# Switch to the non-root user before running the app
|
| 23 |
+
USER user
|
| 24 |
+
|
| 25 |
+
# Command to run the FastAPI server
|
| 26 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|