Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +24 -0
Dockerfile
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a slim Python image for smaller size
|
| 2 |
+
FROM python:3.10-slim-buster
|
| 3 |
+
|
| 4 |
+
# Set the working directory in the container
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Copy only requirements first to leverage Docker cache
|
| 8 |
+
COPY requirements.txt .
|
| 9 |
+
|
| 10 |
+
# Install Python dependencies
|
| 11 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
+
|
| 13 |
+
# Copy the rest of your application code
|
| 14 |
+
COPY . .
|
| 15 |
+
|
| 16 |
+
# Expose the port Uvicorn will run on
|
| 17 |
+
# Hugging Face Spaces exposes port 7860 by default for external access
|
| 18 |
+
# But your Uvicorn server should still run on a specific port internally, e.g., 8000
|
| 19 |
+
EXPOSE 8000
|
| 20 |
+
|
| 21 |
+
# Command to run your FastAPI application using Uvicorn
|
| 22 |
+
# The --host 0.0.0.0 makes it accessible from outside the container
|
| 23 |
+
# The --port 8000 is your internal container port
|
| 24 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|