cloudunity commited on
Commit
c16c3a7
·
verified ·
1 Parent(s): ecc643a

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +46 -0
Dockerfile ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 \
8
+ libglib2.0-0 \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+ # ---- App directory ----
12
+ WORKDIR /app
13
+
14
+ # ---- Python dependencies ----
15
+ COPY requirements.txt /app/requirements.txt
16
+ RUN pip install --no-cache-dir --upgrade pip && \
17
+ pip install --no-cache-dir -r /app/requirements.txt
18
+
19
+ # ---- Pre-download the model at build time ----
20
+ # This bakes the model weights into the image so the container starts
21
+ # fast and does not need network access to Hugging Face at runtime.
22
+ ARG IMAGE_MODEL=stabilityai/sd-turbo
23
+ ENV IMAGE_MODEL=${IMAGE_MODEL}
24
+ RUN hf download ${IMAGE_MODEL} --local-dir /app/models/sd-turbo
25
+
26
+ # ---- Copy application code ----
27
+ COPY server.py /app/server.py
28
+
29
+ # ---- Environment defaults ----
30
+ ENV MODEL_LOCAL_DIR=/app/models/sd-turbo
31
+ ENV DEFAULT_STEPS=2
32
+ ENV DEFAULT_GUIDANCE=0
33
+ ENV PYTHONUNBUFFERED=1
34
+ ENV HF_HOME=/app/.cache/huggingface
35
+ ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
36
+
37
+ # ---- HF Spaces requires a non-root user with UID 1000 ----
38
+ RUN useradd -m -u 1000 appuser && \
39
+ mkdir -p /app/.cache/huggingface && \
40
+ chown -R appuser:appuser /app
41
+
42
+ USER 1000
43
+
44
+ EXPOSE 7860
45
+
46
+ CMD ["python", "server.py"]