vboxuser commited on
Commit
6ef5e2a
·
1 Parent(s): b3e7432

user and permission add on dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -5
Dockerfile CHANGED
@@ -1,13 +1,25 @@
1
  FROM python:3.9
2
 
3
- WORKDIR /code
 
4
 
5
- RUN apt-get update && apt-get install libgl1 ffmpeg libsm6 libxext6 -y
 
 
6
 
7
- COPY ./requirements.txt /code/requirements.txt
 
8
 
9
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
 
10
 
 
11
  COPY . .
 
 
 
 
12
 
13
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
  FROM python:3.9
2
 
3
+ # Create a new user and group with UID/GID 1000
4
+ RUN groupadd -r myapp && useradd -r -g myapp -u 1000 myapp
5
 
6
+ # Create the working directory and set the ownership to the new user and group
7
+ RUN mkdir /code && chown myapp:myapp /code
8
+ WORKDIR /code
9
 
10
+ # Install system dependencies
11
+ RUN apt-get update && apt-get install -y libgl1 ffmpeg libsm6 libxext6
12
 
13
+ # Install Python dependencies
14
+ COPY requirements.txt .
15
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
16
 
17
+ # Copy the rest of the code and set the ownership to the new user and group
18
  COPY . .
19
+ RUN chown -R myapp:myapp .
20
+
21
+ # Switch to the new user
22
+ USER myapp
23
 
24
+ # Start the application
25
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]