Spaces:
Sleeping
Sleeping
Commit
•
63bdccf
1
Parent(s):
3ef2b3b
Update Dockerfile
Browse files- Dockerfile +17 -12
Dockerfile
CHANGED
@@ -1,22 +1,27 @@
|
|
1 |
FROM python:3.10.11
|
2 |
|
3 |
-
#
|
4 |
-
COPY .
|
5 |
-
|
6 |
-
# Set the working directory to /
|
7 |
-
WORKDIR /
|
8 |
-
|
9 |
-
# Install requirements.txt
|
10 |
-
RUN pip install --no-cache-dir --upgrade -r /requirements.txt
|
11 |
|
|
|
12 |
RUN useradd -m -u 1000 user
|
13 |
-
|
|
|
14 |
ENV HOME=/home/user \
|
15 |
-
|
16 |
|
|
|
17 |
WORKDIR $HOME/app
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
# Start the FastAPI app on port 7860, the default port expected by Spaces
|
22 |
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
FROM python:3.10.11
|
2 |
|
3 |
+
# Install dependencies from requirements.txt
|
4 |
+
COPY requirements.txt /tmp/
|
5 |
+
RUN pip install --no-cache-dir --upgrade -r /tmp/requirements.txt && rm /tmp/requirements.txt
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
# Create a non-root user with a home directory
|
8 |
RUN useradd -m -u 1000 user
|
9 |
+
|
10 |
+
# Set environment variables
|
11 |
ENV HOME=/home/user \
|
12 |
+
PATH=/home/user/.local/bin:$PATH
|
13 |
|
14 |
+
# Set working directory to the home directory of the user
|
15 |
WORKDIR $HOME/app
|
16 |
|
17 |
+
# Copy the application code and set the correct permissions
|
18 |
+
COPY --chown=user:user . $HOME/app
|
19 |
+
|
20 |
+
# Switch to the non-root user
|
21 |
+
USER user
|
22 |
+
|
23 |
+
# Expose the port that the FastAPI app will run on
|
24 |
+
EXPOSE 7860
|
25 |
|
26 |
+
# Start the FastAPI app on port 7860, the default port expected by Hugging Face Spaces
|
27 |
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]
|