MingDoan commited on
Commit
d865cc8
·
1 Parent(s): 3aa740f

fix: OpenCV libs

Browse files
Files changed (1) hide show
  1. Dockerfile +33 -10
Dockerfile CHANGED
@@ -1,16 +1,39 @@
1
- FROM python:3.10.13-slim-bookworm
 
2
 
3
- # Define the working directory
4
- WORKDIR /code
 
5
 
6
- # Copy the requirements file
7
- COPY ./requirements.txt /code/requirements.txt
 
 
 
 
8
 
9
- # Install the requirements
10
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
11
 
12
- # Copy the rest of the files
13
- COPY . /code
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  # Run the application
16
- ENTRYPOINT ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Base image: python:3.11.7-slim-bookworm
2
+ FROM python:3.11.7-slim-bookworm
3
 
4
+ # Set environment variables
5
+ ENV CLOUD_HOME=/home/user \
6
+ PATH=/home/user/.local/bin:$PATH
7
 
8
+ # Install libgl1-mesa-glx for opencv
9
+ RUN apt-get update -y
10
+ RUN apt install libgl1-mesa-glx -y
11
+ RUN apt-get install 'ffmpeg'\
12
+ 'libsm6'\
13
+ 'libxext6' -y
14
 
15
+ # Setup new user named user with UID 1000
16
+ RUN useradd -m -u 1000 user
17
 
18
+ # Define working directory
19
+ WORKDIR $CLOUD_HOME/app
20
+
21
+ # Switch to user
22
+ USER user
23
+
24
+ # Copy requirements.txt to the image
25
+ COPY --chown=user:user ./requirements.txt /app/requirements.txt
26
+
27
+ # Install python dependencies
28
+ RUN pip install --no-cache-dir --upgrade pip
29
+ RUN pip install --user -r /app/requirements.txt
30
+
31
+ # Copy the rest of the code to the image
32
+ COPY --chown=user:user . $CLOUD_HOME/app
33
+
34
+ # Expose port 7860
35
+ EXPOSE 7860/tcp
36
+ EXPOSE 7860/udp
37
 
38
  # Run the application
39
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]