Update Dockerfile
Browse files- Dockerfile +19 -10
Dockerfile
CHANGED
@@ -1,20 +1,29 @@
|
|
1 |
-
#
|
2 |
-
FROM python:3.
|
3 |
|
4 |
-
# Set
|
|
|
|
|
|
|
|
|
5 |
WORKDIR /app
|
6 |
|
7 |
-
#
|
|
|
|
|
|
|
|
|
8 |
COPY requirements.txt .
|
9 |
|
10 |
-
# Install
|
|
|
11 |
RUN pip install --no-cache-dir -r requirements.txt
|
12 |
|
13 |
-
# Copy the
|
14 |
COPY . .
|
15 |
|
16 |
-
# Expose
|
17 |
-
EXPOSE
|
18 |
|
19 |
-
# Command to run the
|
20 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "
|
|
|
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"]
|