cloudunity commited on
Commit
23d57e6
·
verified ·
1 Parent(s): e146485

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -11
Dockerfile CHANGED
@@ -1,42 +1,40 @@
1
  FROM python:3.11-slim
2
 
3
- # ---- System dependencies ----
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
5
  build-essential \
6
  libgl1 \
7
  libglib2.0-0 \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
- # ---- App directory ----
11
  WORKDIR /app
12
 
13
- # ---- Python dependencies ----
14
  COPY requirements.txt /app/requirements.txt
15
  RUN pip install --no-cache-dir --upgrade pip
16
 
17
- # Install torch from the CPU-only wheel index first
18
  RUN pip install --no-cache-dir torch==2.3.1 --index-url https://download.pytorch.org/whl/cpu
19
 
20
- # Install the remaining Python dependencies
21
  RUN pip install --no-cache-dir -r /app/requirements.txt
22
 
23
- # ---- Create the non-root user ----
24
- RUN (useradd -m -u 1000 appuser || true) && \
25
- mkdir -p /app/models /app/.cache/huggingface && \
26
  chown -R 1000:1000 /app
27
 
28
- # ---- Pre-download the model at build time ----
 
 
 
29
  ARG IMAGE_MODEL=stabilityai/sd-turbo
30
  ENV IMAGE_MODEL=${IMAGE_MODEL}
31
  ENV HF_HOME=/app/.cache/huggingface
 
32
  ENV HF_HUB_ENABLE_HF_TRANSFER=0
33
  RUN python -m huggingface_hub.commands.huggingface_cli download ${IMAGE_MODEL} --local-dir /app/models/sd-turbo
34
 
35
- # ---- Copy application code ----
36
  COPY server.py /app/server.py
37
  RUN chown 1000:1000 /app/server.py
38
 
39
- # ---- Environment defaults (updated for better quality) ----
40
  ENV MODEL_LOCAL_DIR=/app/models/sd-turbo
41
  ENV DEFAULT_STEPS=4
42
  ENV DEFAULT_GUIDANCE=1.0
 
1
  FROM python:3.11-slim
2
 
3
+ # System dependencies
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
5
  build-essential \
6
  libgl1 \
7
  libglib2.0-0 \
8
  && rm -rf /var/lib/apt/lists/*
9
 
 
10
  WORKDIR /app
11
 
 
12
  COPY requirements.txt /app/requirements.txt
13
  RUN pip install --no-cache-dir --upgrade pip
14
 
15
+ # CPU-only torch
16
  RUN pip install --no-cache-dir torch==2.3.1 --index-url https://download.pytorch.org/whl/cpu
17
 
 
18
  RUN pip install --no-cache-dir -r /app/requirements.txt
19
 
20
+ # Create writable cache directories BEFORE switching user
21
+ RUN mkdir -p /app/.cache/huggingface/hub /app/models && \
 
22
  chown -R 1000:1000 /app
23
 
24
+ # Non-root user
25
+ RUN useradd -m -u 1000 appuser || true
26
+
27
+ # Pre-download model
28
  ARG IMAGE_MODEL=stabilityai/sd-turbo
29
  ENV IMAGE_MODEL=${IMAGE_MODEL}
30
  ENV HF_HOME=/app/.cache/huggingface
31
+ ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
32
  ENV HF_HUB_ENABLE_HF_TRANSFER=0
33
  RUN python -m huggingface_hub.commands.huggingface_cli download ${IMAGE_MODEL} --local-dir /app/models/sd-turbo
34
 
 
35
  COPY server.py /app/server.py
36
  RUN chown 1000:1000 /app/server.py
37
 
 
38
  ENV MODEL_LOCAL_DIR=/app/models/sd-turbo
39
  ENV DEFAULT_STEPS=4
40
  ENV DEFAULT_GUIDANCE=1.0