Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +18 -5
Dockerfile
CHANGED
@@ -1,16 +1,29 @@
|
|
1 |
-
#
|
2 |
-
# you will also find guides on how best to write your Dockerfile
|
3 |
-
|
4 |
FROM python:3.11
|
5 |
|
|
|
6 |
WORKDIR /code
|
7 |
|
|
|
8 |
COPY ./requirements.txt /code/requirements.txt
|
9 |
-
|
10 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
|
|
14 |
COPY . .
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
+
# Use the official Python image
|
|
|
|
|
2 |
FROM python:3.11
|
3 |
|
4 |
+
# Set the working directory inside the container
|
5 |
WORKDIR /code
|
6 |
|
7 |
+
# Copy the requirements file and install dependencies
|
8 |
COPY ./requirements.txt /code/requirements.txt
|
|
|
9 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
10 |
|
11 |
+
# Create the Hugging Face cache directory, set permissions, and create a non-root user
|
12 |
+
RUN mkdir -p /.cache/huggingface/hub && \
|
13 |
+
chmod -R 777 /.cache/huggingface && \
|
14 |
+
useradd -m nonrootuser
|
15 |
+
|
16 |
+
# Set ownership of the .cache directory to the non-root user
|
17 |
+
RUN chown -R nonrootuser:nonrootuser /.cache/huggingface
|
18 |
|
19 |
+
# Copy the rest of the application code
|
20 |
COPY . .
|
21 |
|
22 |
+
# Change ownership of the application code to the non-root user
|
23 |
+
RUN chown -R nonrootuser:nonrootuser /code
|
24 |
+
|
25 |
+
# Switch to the non-root user
|
26 |
+
USER nonrootuser
|
27 |
+
|
28 |
+
# Specify the command to run the application
|
29 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|