cloudunity commited on
Commit
508b792
·
verified ·
1 Parent(s): f75b004

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +6 -14
Dockerfile CHANGED
@@ -1,7 +1,6 @@
1
  FROM python:3.11-slim
2
 
3
  # ---- System dependencies ----
4
- # Minimal apt packages needed to build/run torch + pillow on CPU.
5
  RUN apt-get update && apt-get install -y --no-install-recommends \
6
  build-essential \
7
  libgl1 \
@@ -15,25 +14,18 @@ WORKDIR /app
15
  COPY requirements.txt /app/requirements.txt
16
  RUN pip install --no-cache-dir --upgrade pip
17
 
18
- # Install torch from the CPU-only wheel index first. This avoids pulling
19
- # in the ~2GB of NVIDIA CUDA/cuDNN packages that the default PyPI wheel
20
- # depends on, which are useless (and wasteful) on this CPU-only Space.
21
  RUN pip install --no-cache-dir torch==2.3.1 --index-url https://download.pytorch.org/whl/cpu
22
 
23
- # Install the remaining Python dependencies.
24
  RUN pip install --no-cache-dir -r /app/requirements.txt
25
 
26
- # ---- Create the non-root user required by HF Spaces before downloading ----
27
- # so the downloaded model is owned by the right user from the start
28
- # (avoids a slow recursive chown of multi-GB model weights later).
29
- # "|| true" guards against a base-image UID/GID 1000 already existing.
30
  RUN (useradd -m -u 1000 appuser || true) && \
31
  mkdir -p /app/models /app/.cache/huggingface && \
32
  chown -R 1000:1000 /app
33
 
34
  # ---- Pre-download the model at build time ----
35
- # This bakes the model weights into the image so the container starts
36
- # fast and does not need network access to Hugging Face at runtime.
37
  ARG IMAGE_MODEL=stabilityai/sd-turbo
38
  ENV IMAGE_MODEL=${IMAGE_MODEL}
39
  ENV HF_HOME=/app/.cache/huggingface
@@ -44,10 +36,10 @@ RUN python -m huggingface_hub.commands.huggingface_cli download ${IMAGE_MODEL} -
44
  COPY server.py /app/server.py
45
  RUN chown 1000:1000 /app/server.py
46
 
47
- # ---- Environment defaults ----
48
  ENV MODEL_LOCAL_DIR=/app/models/sd-turbo
49
- ENV DEFAULT_STEPS=2
50
- ENV DEFAULT_GUIDANCE=0
51
  ENV PYTHONUNBUFFERED=1
52
 
53
  USER 1000
 
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 \
 
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
 
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
43
  ENV PYTHONUNBUFFERED=1
44
 
45
  USER 1000