Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +14 -5
Dockerfile
CHANGED
@@ -1,24 +1,33 @@
|
|
1 |
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
# you will also find guides on how best to write your Dockerfile
|
3 |
|
|
|
4 |
FROM python:3.9
|
5 |
|
|
|
6 |
WORKDIR /code
|
7 |
|
|
|
8 |
COPY ./requirements.txt /code/requirements.txt
|
9 |
|
10 |
-
|
|
|
11 |
|
|
|
12 |
RUN useradd -m -u 1000 user
|
13 |
|
|
|
14 |
USER user
|
15 |
|
16 |
-
|
17 |
-
|
|
|
18 |
|
|
|
19 |
WORKDIR $HOME/app
|
20 |
|
|
|
21 |
COPY --chown=user . $HOME/app
|
22 |
|
23 |
-
|
24 |
-
CMD ["uvicorn", "
|
|
|
1 |
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
# you will also find guides on how best to write your Dockerfile
|
3 |
|
4 |
+
# Use the official Python 3.9 image as the base image
|
5 |
FROM python:3.9
|
6 |
|
7 |
+
# Set the working directory to /code
|
8 |
WORKDIR /code
|
9 |
|
10 |
+
# Copy the requirements file into the container at /code/
|
11 |
COPY ./requirements.txt /code/requirements.txt
|
12 |
|
13 |
+
# Install the required Python packages from requirements.txt
|
14 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
15 |
|
16 |
+
# Create a non-root user (optional but recommended for security)
|
17 |
RUN useradd -m -u 1000 user
|
18 |
|
19 |
+
# Switch to the non-root user
|
20 |
USER user
|
21 |
|
22 |
+
# Define environment variables
|
23 |
+
ENV HOME=/home/user \
|
24 |
+
PATH=/home/user/.local/bin:$PATH
|
25 |
|
26 |
+
# Change the working directory to /home/user/app
|
27 |
WORKDIR $HOME/app
|
28 |
|
29 |
+
# Copy the rest of the application files into the container
|
30 |
COPY --chown=user . $HOME/app
|
31 |
|
32 |
+
# Specify the command to run your application (modify as needed)
|
33 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|