Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +23 -13
Dockerfile
CHANGED
|
@@ -1,29 +1,39 @@
|
|
| 1 |
### use the official python3.12 image
|
| 2 |
FROM python:3.12
|
| 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 any needed packages specified in requirements.txt
|
| 11 |
-
RUN pip install --no-cache-dir --upgrade-r /code/requirements.txt
|
| 12 |
|
| 13 |
## set up a new user
|
| 14 |
RUN useradd user
|
| 15 |
-
#switch to the new user
|
| 16 |
USER user
|
| 17 |
|
| 18 |
-
# set the home to user's home directory
|
| 19 |
-
ENV HOME
|
| 20 |
-
PATH
|
|
|
|
| 21 |
|
| 22 |
-
# set the working directory to the user's home directory
|
| 23 |
WORKDIR $HOME/app
|
| 24 |
|
| 25 |
-
# copy the current directory contents into the container at $HOMR/app (home app folder) setting the owner to the new user
|
| 26 |
-
COPY --chown=user . $HOME/app
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
|
|
|
| 29 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7680"]
|
|
|
|
|
|
|
|
|
| 1 |
### use the official python3.12 image
|
| 2 |
FROM python:3.12
|
| 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 |
+
COPY requirements.txt /code/requirements.txt
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
## install any needed packages specified in requirements.txt
|
| 13 |
+
# RUN pip install --no-cache-dir --upgrade-r /code/requirements.txt
|
| 14 |
+
RUN pip install --no-cache-dir -r /code/requirements.txt
|
| 15 |
|
|
|
|
|
|
|
| 16 |
|
| 17 |
## set up a new user
|
| 18 |
RUN useradd user
|
| 19 |
+
## switch to the new user
|
| 20 |
USER user
|
| 21 |
|
| 22 |
+
## set the home to user's home directory
|
| 23 |
+
ENV HOME=/home/user \
|
| 24 |
+
PATH=/home/user/.local/bin:$PATH
|
| 25 |
+
|
| 26 |
|
| 27 |
+
## set the working directory to the user's home directory
|
| 28 |
WORKDIR $HOME/app
|
| 29 |
|
| 30 |
+
## copy the current directory contents into the container at $HOMR/app (home app folder) setting the owner to the new user
|
| 31 |
+
# COPY --chown=user . $HOME/app
|
| 32 |
+
RUN mkdir -p $HOME/app && chown -R user:user $HOME/app
|
| 33 |
+
COPY --chown=user:user . $HOME/app
|
| 34 |
|
| 35 |
+
|
| 36 |
+
## Start the FASTAPI App on port 7680
|
| 37 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7680"]
|
| 38 |
+
|
| 39 |
+
|