Update Dockerfile
Browse files- Dockerfile +15 -11
Dockerfile
CHANGED
|
@@ -1,20 +1,24 @@
|
|
| 1 |
-
# Use
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
-
#
|
|
|
|
|
|
|
|
|
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Copy
|
| 8 |
COPY requirements.txt .
|
| 9 |
-
|
| 10 |
-
# Install dependencies
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
-
# Copy the
|
| 14 |
-
COPY
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
#
|
| 17 |
EXPOSE 7860
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
CMD ["uvicorn", "
|
|
|
|
| 1 |
+
# Use official Python lightweight image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
|
| 4 |
+
# Hugging Face requires creating a specific user to run the container
|
| 5 |
+
RUN useradd -m -u 1000 user
|
| 6 |
+
|
| 7 |
+
# Set working directory
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
+
# Copy requirements and install
|
| 11 |
COPY requirements.txt .
|
|
|
|
|
|
|
| 12 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
|
| 14 |
+
# Copy the entire app
|
| 15 |
+
COPY --chown=user:user . /app
|
| 16 |
+
|
| 17 |
+
# Switch to the non-root user
|
| 18 |
+
USER user
|
| 19 |
|
| 20 |
+
# Hugging Face Spaces route web traffic to port 7860
|
| 21 |
EXPOSE 7860
|
| 22 |
|
| 23 |
+
# Run FastAPI using Uvicorn
|
| 24 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|