Genzo1010 commited on
Commit
414380c
·
verified ·
1 Parent(s): 7adee70

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -15
Dockerfile CHANGED
@@ -1,22 +1,34 @@
1
- # Use the official Python image as a base image
2
- FROM python:3.9
3
 
4
- # Set the working directory in the container
5
- WORKDIR /app
 
 
6
 
7
- # Copy the requirements file to the container
8
- COPY requirements.txt .
9
 
10
- # Install any necessary dependencies
11
- RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Copy the rest of the application code to the container
14
- COPY . .
15
 
16
- # Expose the port that the FastAPI app will run on
17
- EXPOSE 8000
18
 
19
- ##
20
 
21
- # Command to run the FastAPI app using Uvicorn
22
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python 3.10 for compatibility with newer packages
2
+ FROM python:3.10
3
 
4
+ # Install required system dependencies
5
+ RUN apt-get update && apt-get install -y \
6
+ libgl1-mesa-glx \
7
+ libglib2.0-0
8
 
9
+ RUN useradd user
 
10
 
11
+ USER user
 
12
 
13
+ ENV HOME=/home/user \
14
+ PATH=/home/user/.local/bin:$PATH
15
 
16
+ # Set up a working directory
17
+ WORKDIR $HOME/app
18
 
19
+ COPY --chown=user ./ $HOME/app
20
 
21
+ # Install dependencies from the requirements file
22
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
23
+
24
+ # Install PyTorch and torchvision
25
+ RUN pip install torch torchvision
26
+
27
+ # Set environment variable to indicate PyTorch usage
28
+ ENV USE_TORCH=1
29
+
30
+ # Expose port 7860 for the app
31
+ EXPOSE 1326
32
+
33
+ # Command to run FastAPI app with Uvicorn
34
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "1326"]