Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +12 -13
Dockerfile
CHANGED
|
@@ -1,20 +1,19 @@
|
|
| 1 |
-
FROM python:3.9
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
|
| 16 |
-
# Expose the
|
| 17 |
EXPOSE 7860
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
# Copy requirements first to leverage Docker cache
|
| 3 |
+
COPY --chown=user requirements.txt .
|
| 4 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 5 |
|
| 6 |
+
# Copy application code
|
| 7 |
+
COPY --chown=user . .
|
| 8 |
|
| 9 |
+
# Create models directory
|
| 10 |
+
RUN mkdir -p models && chown user:user models
|
|
|
|
| 11 |
|
| 12 |
+
# Switch to non-root user
|
| 13 |
+
USER user
|
| 14 |
|
| 15 |
+
# Expose the port
|
| 16 |
EXPOSE 7860
|
| 17 |
|
| 18 |
+
# Command to run the application
|
| 19 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|