charbel-malo commited on
Commit
cb13419
·
verified ·
1 Parent(s): dfd898c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -15
Dockerfile CHANGED
@@ -1,27 +1,30 @@
1
  # Use an official Python runtime as a parent image
2
- FROM python:3.9-slim
3
 
4
- # Set environment variables to reduce Python buffering and prevent .pyc files
 
 
 
 
 
 
 
5
  ENV PYTHONDONTWRITEBYTECODE=1
6
  ENV PYTHONUNBUFFERED=1
7
 
8
- # Create a non-root user to run the app
9
- RUN useradd -m -u 1000 appuser
10
- USER appuser
11
-
12
  # Set the working directory
13
  WORKDIR /app
14
 
15
  # Copy and install dependencies
16
- COPY --chown=appuser:appuser requirements.txt .
17
- RUN pip install --no-cache-dir --upgrade pip && \
18
- pip install --no-cache-dir -r requirements.txt
19
 
20
- # Copy the application code
21
- COPY --chown=appuser:appuser . .
22
 
23
- # Expose the port FastAPI will run on
24
- EXPOSE 7860
25
 
26
- # Command to run the application
27
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  # Use an official Python runtime as a parent image
2
+ FROM python:3.10-slim
3
 
4
+ # Create a user with a non-root UID
5
+ RUN useradd -m -u 1000 user
6
+
7
+ # Switch to the non-root user
8
+ USER user
9
+
10
+ # Set environment variables
11
+ ENV PATH="/home/user/.local/bin:$PATH"
12
  ENV PYTHONDONTWRITEBYTECODE=1
13
  ENV PYTHONUNBUFFERED=1
14
 
 
 
 
 
15
  # Set the working directory
16
  WORKDIR /app
17
 
18
  # Copy and install dependencies
19
+ COPY --chown=user: /app/requirements.txt .
20
+ RUN pip install --no-cache-dir --upgrade pip
21
+ RUN pip install --no-cache-dir -r requirements.txt
22
 
23
+ # Copy the rest of the application code
24
+ COPY --chown=user: /app /app
25
 
26
+ # Expose the port your app runs on
27
+ EXPOSE 8080
28
 
29
+ # Define the command to run the app using Gunicorn
30
+ CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"]