merasabkuch commited on
Commit
ffb4bb8
·
verified ·
1 Parent(s): 6964c03

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +33 -26
Dockerfile CHANGED
@@ -1,27 +1,34 @@
1
- # Use Python as base image
2
- FROM python:3.10-slim
3
-
4
- # Set environment variables
5
- ENV PYTHONUNBUFFERED=1 \
6
- PYTHONDONTWRITEBYTECODE=1
7
-
8
- # Set the working directory inside the container
9
- WORKDIR /app
10
-
11
- # Copy the project files into the container
12
- COPY . /app
13
-
14
- # Install system dependencies
15
- RUN apt-get update && apt-get install -y \
16
- gcc \
17
- libpq-dev \
18
- && rm -rf /var/lib/apt/lists/*
19
-
20
- # Install Python dependencies
21
- RUN pip install --upgrade pip && pip install -r requirements.txt
22
-
23
- # Expose the application's port
24
- EXPOSE 8000
25
-
26
- # Start the FastAPI application
 
 
 
 
 
 
 
27
  CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "main:app", "--bind", "0.0.0.0:8000", "--workers", "4"]
 
1
+ # Use Python as base image
2
+ FROM python:3.10-slim
3
+
4
+ # Install system dependencies
5
+ USER root
6
+ RUN apt-get update && apt-get install -y \
7
+ libgl1-mesa-glx \
8
+ && rm -rf /var/lib/apt/lists/*
9
+
10
+ # Set environment variables
11
+ ENV PYTHONUNBUFFERED=1 \
12
+ PYTHONDONTWRITEBYTECODE=1
13
+
14
+ RUN useradd -m -u 1000 user
15
+ USER user
16
+ ENV PATH="/home/user/.local/bin:$PATH"
17
+
18
+
19
+ # Set the working directory inside the container
20
+ WORKDIR /app
21
+
22
+
23
+ # Copy the project files into the container
24
+ COPY . /app
25
+
26
+ COPY --chown=user ./requirements.txt requirements.txt
27
+ # Install Python dependencies
28
+ RUN pip install --upgrade pip && pip install -r requirements.txt
29
+
30
+ # Expose the application's port
31
+ EXPOSE 8000
32
+
33
+ # Start the FastAPI application
34
  CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "main:app", "--bind", "0.0.0.0:8000", "--workers", "4"]