Spaces:
Sleeping
Sleeping
Eslam Magdy
commited on
Update Dockerfile
Browse files- Dockerfile +14 -2
Dockerfile
CHANGED
|
@@ -1,11 +1,23 @@
|
|
| 1 |
FROM python:3.9
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
WORKDIR /code
|
| 4 |
|
|
|
|
| 5 |
COPY ./requirements.txt /code/requirements.txt
|
| 6 |
-
|
| 7 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
COPY . .
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
| 1 |
FROM python:3.9
|
| 2 |
|
| 3 |
+
# Create a new user and group and set them as the default user
|
| 4 |
+
RUN groupadd -r appuser && useradd -r -g appuser appuser
|
| 5 |
+
|
| 6 |
+
# Set the working directory
|
| 7 |
WORKDIR /code
|
| 8 |
|
| 9 |
+
# Copy the requirements file and install dependencies
|
| 10 |
COPY ./requirements.txt /code/requirements.txt
|
|
|
|
| 11 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 12 |
|
| 13 |
+
# Change ownership of the working directory
|
| 14 |
+
RUN chown -R appuser:appuser /code
|
| 15 |
+
|
| 16 |
+
# Switch to the new user
|
| 17 |
+
USER appuser
|
| 18 |
+
|
| 19 |
+
# Copy the rest of the application code
|
| 20 |
COPY . .
|
| 21 |
|
| 22 |
+
# Set the default command
|
| 23 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|