Danialebrat commited on
Commit
a1bbf36
·
1 Parent(s): a371525

Modifying Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -24
Dockerfile CHANGED
@@ -1,34 +1,37 @@
1
- # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
- # --------------------------------------------------------------
3
- # Base image
4
  FROM python:3.9
5
 
6
- # --------------------------------------------------------------
7
- # 1. create and switch to – the un-privileged UID 1000 account
8
  RUN useradd -m -u 1000 user
9
- USER user
10
 
11
- # make sure pip-installed CLI tools are on PATH
 
12
  ENV HOME=/home/user \
13
- PATH="$HOME/.local/bin:$PATH" \
14
  PYTHONUNBUFFERED=1 \
15
- PIP_NO_CACHE_DIR=1
16
-
17
- # --------------------------------------------------------------
18
- # 2. project files and Python deps
19
- WORKDIR $HOME/app
20
 
21
- # install requirements first so Docker can cache the layer
22
- COPY --chown=user requirements.txt .
23
- RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
24
 
25
- # copy the rest of the source tree
 
 
 
 
26
  COPY --chown=user . .
27
 
28
- # --------------------------------------------------------------
29
- # 3. launch the app
30
-
31
- # Hugging Face injects $PORT at runtime; use shell-form CMD so $PORT expands
32
- CMD streamlit run app.py --server.port=${PORT:-7860} \
33
- --server.headless true \
34
- --server.address 0.0.0.0
 
1
+ # ---------------------------------------------------------------------
2
+ # Base image – use the full tag so `wget` is available for the steps
 
3
  FROM python:3.9
4
 
5
+ # ---------------------------------------------------------------------
6
+ # 1. Create UID-1000 account *and its home directory*.
7
  RUN useradd -m -u 1000 user
 
8
 
9
+ # Environment: declare the home dir now (some HF-injected commands
10
+ # look at $HOME) but stay root for the next layers.
11
  ENV HOME=/home/user \
 
12
  PYTHONUNBUFFERED=1 \
13
+ PIP_NO_CACHE_DIR=1 \
14
+ PATH="$HOME/.local/bin:$PATH"
 
 
 
15
 
16
+ # ---------------------------------------------------------------------
17
+ # 2. Install Python dependencies **as root** so the console scripts
18
+ # land in /usr/local/bin (already on PATH at runtime).
19
+ WORKDIR /app # temporary build context
20
+ COPY requirements.txt /tmp/reqs.txt
21
+ RUN pip install --no-cache-dir -r /tmp/reqs.txt \
22
+ && rm /tmp/reqs.txt
23
 
24
+ # ---------------------------------------------------------------------
25
+ # 3. Switch to the non-root user for the final image,
26
+ # then copy the source tree.
27
+ USER user
28
+ WORKDIR $HOME/app
29
  COPY --chown=user . .
30
 
31
+ # ---------------------------------------------------------------------
32
+ # 4. Launch: $PORT is set by the platform at runtime; fall back to 7860
33
+ # for local docker runs.
34
+ CMD streamlit run app.py \
35
+ --server.port=${PORT:-7860} \
36
+ --server.headless true \
37
+ --server.address 0.0.0.0