ParthSadaria commited on
Commit
b9fbe4a
·
verified ·
1 Parent(s): e2d9c95

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -17
Dockerfile CHANGED
@@ -2,31 +2,29 @@
2
 
3
  FROM python:3.10-slim
4
 
5
- # install tini and system deps
6
  RUN apt-get update && apt-get install -y --no-install-recommends \
7
- tini build-essential \
8
- && apt-get clean \
9
- && rm -rf /var/lib/apt/lists/*
 
 
10
 
11
  # set workdir
12
  WORKDIR /app
13
 
14
- # install python deps first (layer caching)
15
- COPY requirements.txt .
 
 
 
 
 
16
  RUN pip install --no-cache-dir --upgrade pip && \
17
  pip install --no-cache-dir -r requirements.txt
18
 
19
- # copy app code
20
- COPY . .
21
-
22
- # expose port
23
  EXPOSE 7860
24
 
25
- # use tini to forward signals correctly (prevents zombie processes)
26
- ENTRYPOINT ["/usr/bin/tini", "--"]
27
-
28
- # optional: default stop signal
29
- STOPSIGNAL SIGTERM
30
-
31
- # start the app
32
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
2
 
3
  FROM python:3.10-slim
4
 
5
+ # system deps
6
  RUN apt-get update && apt-get install -y --no-install-recommends \
7
+ build-essential \
8
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
9
+
10
+ # create non-root user
11
+ RUN useradd -m -u 1000 user
12
 
13
  # set workdir
14
  WORKDIR /app
15
 
16
+ # change ownership to the new user
17
+ COPY --chown=user:user . .
18
+
19
+ # switch to non-root user
20
+ USER user
21
+
22
+ # install Python deps
23
  RUN pip install --no-cache-dir --upgrade pip && \
24
  pip install --no-cache-dir -r requirements.txt
25
 
26
+ # expose port (HF Spaces uses 7860)
 
 
 
27
  EXPOSE 7860
28
 
29
+ # launch your FastAPI app
 
 
 
 
 
 
30
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]