threeorfour commited on
Commit
9232d48
·
verified ·
1 Parent(s): 5f83cd9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -10
Dockerfile CHANGED
@@ -1,15 +1,33 @@
1
- # Use a specific version of Python for stability
2
  FROM python:3.9-slim
3
 
4
- # Set the working directory
5
- WORKDIR /code
6
 
7
- # Copy requirements and install them
8
- COPY ./requirements.txt /code/requirements.txt
9
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
 
 
 
 
 
10
 
11
- # Copy your application
12
- COPY ./app.py /code/app.py
 
 
13
 
14
- # Command to run the Uvicorn server
15
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use a stable Python base image
2
  FROM python:3.9-slim
3
 
4
+ # Set environment variables to prevent interactive prompts during installation
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
 
7
+ # Install necessary system dependencies, including Chromium and Xvfb
8
+ RUN apt-get update && \
9
+ apt-get install -y --no-install-recommends \
10
+ chromium \
11
+ chromium-driver \
12
+ xvfb \
13
+ && \
14
+ apt-get clean && \
15
+ rm -rf /var/lib/apt/lists/*
16
 
17
+ # Create a non-root user for security
18
+ RUN useradd -m appuser
19
+ USER appuser
20
+ WORKDIR /home/appuser/app
21
 
22
+ # Copy the requirements file and install Python packages
23
+ COPY --chown=appuser:appuser requirements.txt .
24
+ RUN pip install --no-cache-dir -r requirements.txt
25
+
26
+ # Copy the application code
27
+ COPY --chown=appuser:appuser main.py .
28
+
29
+ # Expose the port the API will run on
30
+ EXPOSE 7860
31
+
32
+ # The command to run the FastAPI application
33
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]