mikmc5 commited on
Commit
528b0d1
·
verified ·
1 Parent(s): 9146b34

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -11
Dockerfile CHANGED
@@ -1,20 +1,31 @@
1
- # Use the official Python 3.9 slim image
2
- FROM python:3.9-slim
3
 
4
  # Set the working directory in the container
5
  WORKDIR /app
6
 
7
- # Copy the requirements.txt file into the container
8
- COPY requirements.txt .
 
 
 
9
 
10
- # Install the dependencies specified in requirements.txt
 
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Copy the entire application code into the container
14
- COPY . .
 
 
 
 
 
 
 
 
 
15
 
16
- # Expose the port that FastAPI will use
17
- EXPOSE 8000
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