Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +39 -0
Dockerfile
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a recent, slim Python base image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Set the working directory in the container
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Prevent Python from writing pyc files to disc (optional but good practice)
|
| 8 |
+
ENV PYTHONDONTWRITEBYTECODE 1
|
| 9 |
+
# Ensure Python output is sent straight to terminal (useful for logs)
|
| 10 |
+
ENV PYTHONUNBUFFERED 1
|
| 11 |
+
|
| 12 |
+
# Upgrade pip
|
| 13 |
+
RUN python -m pip install --upgrade pip
|
| 14 |
+
|
| 15 |
+
# Copy the requirements file into the container
|
| 16 |
+
# This file should list all necessary Python packages for the project.
|
| 17 |
+
COPY requirements.txt .
|
| 18 |
+
|
| 19 |
+
# Install dependencies
|
| 20 |
+
# --no-cache-dir reduces image size, beneficial for smaller final images.
|
| 21 |
+
# --default-timeout=100 increases timeout for pip install (can be adjusted if needed).
|
| 22 |
+
RUN pip install --no-cache-dir --default-timeout=100 -r requirements.txt
|
| 23 |
+
|
| 24 |
+
# Copy the application code into the container
|
| 25 |
+
# This assumes your FastAPI application is in a file named 'main.py'.
|
| 26 |
+
COPY api.py .
|
| 27 |
+
# If you had other local modules or directories part of your project (e.g., a 'core' or 'utils' folder),
|
| 28 |
+
# you would add more COPY lines here, like:
|
| 29 |
+
# COPY ./your_module_directory ./your_module_directory
|
| 30 |
+
|
| 31 |
+
# Expose the port the app runs on.
|
| 32 |
+
# This should match the port Uvicorn is configured to use in the CMD instruction.
|
| 33 |
+
EXPOSE 7860
|
| 34 |
+
|
| 35 |
+
# Command to run the Uvicorn server
|
| 36 |
+
# It will look for an ASGI application instance named 'app' in the 'main.py' file.
|
| 37 |
+
# Runs on port 7860 and listens on all available network interfaces (0.0.0.0).
|
| 38 |
+
# Note: For production environments, ensure --reload is NOT used as it's for development.
|
| 39 |
+
CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860"]
|