Shivam4096 commited on
Commit
d160fc8
Β·
verified Β·
1 Parent(s): 7bbba88

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -9
Dockerfile CHANGED
@@ -10,24 +10,31 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
10
  curl \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
- # ── App directory ──────────────────────────────────────────────────────────────
14
- WORKDIR /app
 
 
 
 
 
 
 
 
15
 
16
  # ── Install Python dependencies ────────────────────────────────────────────────
17
- COPY web_app/requirements.txt ./requirements.txt
 
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
  # ── Copy full application source ───────────────────────────────────────────────
21
- COPY . .
22
 
23
  # ── Create writable directories ────────────────────────────────────────────────
24
- RUN mkdir -p outputs storage web_app/__pycache__ \
25
- && chmod -R 777 /app
26
 
27
  # ── Streamlit config β€” disable telemetry, set port ────────────────────────────
28
- RUN mkdir -p .streamlit \
29
- && cp web_app/streamlit_config.toml .streamlit/config.toml \
30
- && chmod -R 777 .streamlit
31
 
32
  # ── HF Spaces: port 7860 ──────────────────────────────────────────────────────
33
  EXPOSE 7860
 
10
  curl \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
+ # ── Create a non-root user (Required for Hugging Face Spaces) ──────────────────
14
+ RUN useradd -m -u 1000 user
15
+ USER user
16
+
17
+ # ── Setup environment ──────────────────────────────────────────────────────────
18
+ ENV HOME=/home/user \
19
+ PATH=/home/user/.local/bin:$PATH
20
+
21
+ # Set the working directory to the user's home directory
22
+ WORKDIR $HOME/app
23
 
24
  # ── Install Python dependencies ────────────────────────────────────────────────
25
+ # Copy requirements first to leverage Docker cache
26
+ COPY --chown=user web_app/requirements.txt ./requirements.txt
27
  RUN pip install --no-cache-dir -r requirements.txt
28
 
29
  # ── Copy full application source ───────────────────────────────────────────────
30
+ COPY --chown=user . $HOME/app
31
 
32
  # ── Create writable directories ────────────────────────────────────────────────
33
+ RUN mkdir -p outputs storage web_app/__pycache__
 
34
 
35
  # ── Streamlit config β€” disable telemetry, set port ────────────────────────────
36
+ RUN mkdir -p $HOME/.streamlit \
37
+ && cp web_app/streamlit_config.toml $HOME/.streamlit/config.toml
 
38
 
39
  # ── HF Spaces: port 7860 ──────────────────────────────────────────────────────
40
  EXPOSE 7860