Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +22 -11
Dockerfile
CHANGED
|
@@ -1,20 +1,31 @@
|
|
| 1 |
-
# Use the official Python
|
| 2 |
-
FROM python:3.
|
| 3 |
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
# Install
|
|
|
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
-
# Copy the
|
| 14 |
-
COPY .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
|
| 19 |
-
# Start the FastAPI app with Gunicorn for better performance
|
| 20 |
-
CMD ["gunicorn", "app:app_", "--bind", "0.0.0.0:8000", "--log-level", "debug", "--access-logfile", "-"]
|
|
|
|
| 1 |
+
# Use the official Python image as the base image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
|
| 4 |
# Set the working directory in the container
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Install system dependencies (e.g., for building wheel, working with requests, etc.)
|
| 8 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 9 |
+
gcc \
|
| 10 |
+
libpq-dev \
|
| 11 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
+
# Install Python dependencies
|
| 14 |
+
COPY requirements.txt .
|
| 15 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 16 |
|
| 17 |
+
# Copy the application code into the container
|
| 18 |
+
COPY . /app/
|
| 19 |
+
|
| 20 |
+
# Expose the port the app will run on
|
| 21 |
+
EXPOSE 80
|
| 22 |
+
|
| 23 |
+
# Set the environment variable for Python to run in optimized mode
|
| 24 |
+
ENV PYTHONUNBUFFERED 1
|
| 25 |
+
|
| 26 |
+
# Install Uvicorn and Gunicorn for serving the app with FastAPI
|
| 27 |
+
RUN pip install uvicorn gunicorn
|
| 28 |
|
| 29 |
+
# Start the FastAPI app using Gunicorn with the Uvicorn worker class
|
| 30 |
+
CMD ["gunicorn", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "main:app_"]
|
| 31 |
|
|
|
|
|
|