Kashish commited on
Commit
83604ad
·
1 Parent(s): 7744be2

run docker container as non-root user

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -5
Dockerfile CHANGED
@@ -1,18 +1,24 @@
1
  FROM python:3.13-slim
2
 
3
- WORKDIR /app
 
 
4
 
5
- COPY requirements.txt ./
 
 
6
 
7
- RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
 
 
8
 
 
9
  RUN pip install --no-cache-dir -r requirements.txt
10
 
11
- COPY . .
12
 
13
  RUN python build_index.py
14
 
15
- ENV PYTHONUNBUFFERED=1
16
  EXPOSE 7860
17
 
18
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM python:3.13-slim
2
 
3
+ # Create user with UID 1000
4
+ RUN useradd -m -u 1000 user
5
+ USER user
6
 
7
+ ENV HOME=/home/user \
8
+ PATH=/home/user/.local/bin:$PATH \
9
+ PYTHONUNBUFFERED=1
10
 
11
+ WORKDIR $HOME/app
12
+
13
+ COPY --chown=user requirements.txt ./
14
 
15
+ RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
16
  RUN pip install --no-cache-dir -r requirements.txt
17
 
18
+ COPY --chown=user . .
19
 
20
  RUN python build_index.py
21
 
 
22
  EXPOSE 7860
23
 
24
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]