FROM ubuntu:22.04 AS builder ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential cmake git ca-certificates libopenblas-dev pkg-config \ && rm -rf /var/lib/apt/lists/* WORKDIR /build RUN git clone --depth 1 https://github.com/leejet/stable-diffusion.cpp.git . \ && git submodule update --init --depth 1 RUN mkdir build && cd build \ && cmake .. -DGGML_BLAS=ON -DSD_BUILD_SHARED_LIBS=OFF \ && cmake --build . --config Release -j1 RUN mkdir -p /artifacts \ && cp /build/build/bin/sd-cli /artifacts/ \ && (cp -a /build/build/bin/lib*.so* /artifacts/ 2>/dev/null || true) # --------------------------------------------------------------------------- # Runtime image # --------------------------------------------------------------------------- FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y --no-install-recommends \ libopenblas0 libgomp1 ca-certificates curl \ python3 python3-pip \ && rm -rf /var/lib/apt/lists/* WORKDIR /app COPY --from=builder /artifacts/ /app/ ENV LD_LIBRARY_PATH=/app:${LD_LIBRARY_PATH} RUN chmod +x /app/sd-cli RUN mkdir -p /app/models # Z-Anime distill 4-step Q5_0 GGUF (~4.23GB) - converted by WeReCooking RUN curl -fL --retry 3 --retry-delay 5 -o /app/models/z-anime-distill-4step-q5_0.gguf \ "https://huggingface.co/WeReCooking/Z-Anime-4step-GGUF/resolve/main/z-anime-distill-4step-q5_0.gguf" # Qwen3-4B text encoder IQ4_XS GGUF (~2.29GB) - smaller for 18GB RAM RUN curl -fL --retry 3 --retry-delay 5 -o /app/models/qwen3_4b_iq4xs.gguf \ "https://huggingface.co/worstplayer/Z-Image_Qwen_3_4b_text_encoder_GGUF/resolve/main/Qwen_3_4b-IQ4_XS.gguf" # VAE (~168MB) RUN curl -fL --retry 3 --retry-delay 5 -o /app/models/ae.safetensors \ "https://huggingface.co/SeeSee21/Z-Anime/resolve/main/vae/ae.safetensors" # Install Python deps RUN pip3 install --no-cache-dir "gradio[mcp]" Pillow COPY app.py /app/app.py EXPOSE 7860 CMD ["python3", "/app/app.py"]