Niansuh commited on
Commit
e1581e4
·
verified ·
1 Parent(s): 1ed9d1d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -10
Dockerfile CHANGED
@@ -1,20 +1,29 @@
1
- # Dockerfile
2
- FROM python:3.11-slim
3
 
4
- # Set the working directory in the container
 
 
 
 
5
  WORKDIR /app
6
 
7
- # Copy the requirements file into the container
 
 
 
 
8
  COPY requirements.txt .
9
 
10
- # Install the dependencies
 
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Copy the application code into the container
14
  COPY . .
15
 
16
- # Expose the port that the app runs on
17
- EXPOSE 8000
18
 
19
- # Command to run the application
20
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
 
1
+ # Use the official Python 3.10 slim image
2
+ FROM python:3.10-slim
3
 
4
+ # Set environment variables to prevent Python from writing pyc files and to buffer stdout/stderr
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
7
+
8
+ # Set the working directory to /app
9
  WORKDIR /app
10
 
11
+ # Install system dependencies (if any)
12
+ # For example, if you need gcc for some packages, uncomment the following line
13
+ # RUN apt-get update && apt-get install -y gcc
14
+
15
+ # Copy only the requirements.txt first to leverage Docker cache
16
  COPY requirements.txt .
17
 
18
+ # Install Python dependencies
19
+ RUN pip install --no-cache-dir --upgrade pip
20
  RUN pip install --no-cache-dir -r requirements.txt
21
 
22
+ # Copy the rest of the application code
23
  COPY . .
24
 
25
+ # Expose port 8001 to the outside world
26
+ EXPOSE 8001
27
 
28
+ # Command to run the FastAPI app with Uvicorn
29
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8001"]