Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +29 -23
Dockerfile
CHANGED
|
@@ -1,24 +1,30 @@
|
|
| 1 |
-
# Use the official Python image
|
| 2 |
-
FROM python:3.
|
| 3 |
-
|
| 4 |
-
# Set the working directory
|
| 5 |
-
WORKDIR /
|
| 6 |
-
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# Use the official Python 3.10 slim image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Set the working directory in the container
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Set environment variables
|
| 8 |
+
# Prevents Python from writing .pyc files and ensures logs are flushed to terminal
|
| 9 |
+
ENV PYTHONDONTWRITEBYTECODE 1
|
| 10 |
+
ENV PYTHONUNBUFFERED 1
|
| 11 |
+
|
| 12 |
+
# Install system dependencies if needed (none required for this specific script)
|
| 13 |
+
# RUN apt-get update && apt-get install -y --no-install-recommends gcc
|
| 14 |
+
|
| 15 |
+
# Copy the requirements file first to leverage Docker cache
|
| 16 |
+
COPY requirements.txt .
|
| 17 |
+
|
| 18 |
+
# Install Python dependencies
|
| 19 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 20 |
+
|
| 21 |
+
# Copy the rest of the application code
|
| 22 |
+
COPY . .
|
| 23 |
+
|
| 24 |
+
# Hugging Face Spaces runs on port 7860 by default
|
| 25 |
+
# We expose this port for documentation
|
| 26 |
+
EXPOSE 7860
|
| 27 |
+
|
| 28 |
+
# Start the FastAPI application using uvicorn
|
| 29 |
+
# We use main:app (assuming your file is named main.py and the FastAPI instance is 'app')
|
| 30 |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|