Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +18 -25
Dockerfile
CHANGED
@@ -1,35 +1,28 @@
|
|
1 |
-
#
|
2 |
-
#listed in requirements.txt, and starts a FastAPI app on port 7860
|
3 |
-
|
4 |
-
#We're going to use the Python 3.9 Docker Image as the base image for our container
|
5 |
FROM python:3.9
|
6 |
-
|
7 |
-
#
|
8 |
WORKDIR /code
|
9 |
-
|
10 |
-
#
|
11 |
COPY ./requirements.txt /code/requirements.txt
|
12 |
-
|
13 |
-
#
|
14 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
15 |
-
|
16 |
-
#
|
17 |
-
#The ENV command sets the HOME and PATH environment variables.
|
18 |
-
#PATH is modified to include the '.local/bin' directory in the user's home directory so that anyt binaries installed by pip will be available on the command line
|
19 |
RUN useradd -m -u 1000 user
|
|
|
20 |
USER user
|
|
|
21 |
ENV HOME=/home/user \\
|
22 |
PATH=/home/user/.local/bin:$PATH
|
23 |
-
|
24 |
-
#
|
25 |
WORKDIR $HOME/app
|
26 |
-
|
27 |
-
#
|
28 |
COPY --chown=user . $HOME/app
|
29 |
-
|
30 |
-
#
|
31 |
-
|
32 |
-
#The '--host' flage specifies that the app should listen on all available network interfaces
|
33 |
-
#The 'app:app' argument tells 'uvicorn' to look for the app object in the app module in our code
|
34 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
35 |
-
|
|
|
1 |
+
# Use the official Python 3.9 image
|
|
|
|
|
|
|
2 |
FROM python:3.9
|
3 |
+
|
4 |
+
# Set the working directory to /code
|
5 |
WORKDIR /code
|
6 |
+
|
7 |
+
# Copy the current directory contents into the container at /code
|
8 |
COPY ./requirements.txt /code/requirements.txt
|
9 |
+
|
10 |
+
# Install requirements.txt
|
11 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
12 |
+
|
13 |
+
# Set up a new user named "user" with user ID 1000
|
|
|
|
|
14 |
RUN useradd -m -u 1000 user
|
15 |
+
# Switch to the "user" user
|
16 |
USER user
|
17 |
+
# Set home to the user's home directory
|
18 |
ENV HOME=/home/user \\
|
19 |
PATH=/home/user/.local/bin:$PATH
|
20 |
+
|
21 |
+
# Set the working directory to the user's home directory
|
22 |
WORKDIR $HOME/app
|
23 |
+
|
24 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
25 |
COPY --chown=user . $HOME/app
|
26 |
+
|
27 |
+
# Start the FastAPI app on port 7860, the default port expected by Spaces
|
28 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|
|
|