[Unit]
Description=A Stable Diffusion CPP Server for Editing Images

[Container]
# Shared AI pod
Pod=ai.pod

# Vulkan image for AMD GPU
Image=localhost/stable-diffusion-cpp:latest

# Shared models directory
Volume=/home/ai/models:/models:z

# GPU Device
AddDevice=/dev/kfd
AddDevice=/dev/dri

# Override entrypoint to use server
Entrypoint=/sd-server

# Server args
Exec=-l 0.0.0.0 \
    --listen-port 1235 \
    --diffusion-model /models/image/flux-1-kontext/flux1-kontext-dev-Q4_K_M.gguf \
    --vae /models/image/flux-1-kontext/ae.safetensors \
    --clip_l /models/image/flux-1-kontext/clip_l.safetensors \
    --t5xxl /models/image/flux-1-kontext/t5xxl_fp16.safetensors \
    --cfg-scale 1.0 \
    --sampling-method euler \
    --vae-conv-direct \
    --seed -1 \
    --steps 28 \
    -v

[Service]
Restart=always
# Extend Timeout to allow time to pull the image
TimeoutStartSec=900

[Install]
# Start by default on boot
WantedBy=multi-user.target default.target
