Build & push a worker image
Project layout
worker/
├── Dockerfile
├── apipods.toml # endpoint settings for `apipods endpoints deploy`
├── handler.py
├── requirements.txt
└── test_input.json # used by local test modeDockerfile
Start from apipods/worker-base:1.9.1-py3.12-cuda12.8.1. It contains CUDA, cuDNN, Python and the apipods SDK, and is cached on every serverless host, so only your own layers have to be pulled.
FROM apipods/worker-base:1.9.1-py3.12-cuda12.8.1
WORKDIR /app
# Install dependencies first so this layer is cached between builds.
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY handler.py .
# -u disables output buffering so logs show up immediately.
CMD ["python", "-u", "handler.py"]apipods>=1.9.1
diffusers==0.35.2
transformers==4.57.1
accelerate==1.11.0You can use any other base image, for example nvidia/cuda or your own, as long as it has Python and apipods installed and the container command starts the handler.
Where to put model weights
| Option | Pros | Cons |
|---|---|---|
| Bake into the image | Self-contained, versioned with your code | Large images pull slowly on the first cold start of each host |
Network volume at /volume | Small image, weights shared by every worker, update without a rebuild | Endpoint is limited to the volume's region |
| Download at startup | Simplest | Every cold start re-downloads; only acceptable for small models |
Build and push
Workers run on linux/amd64. If you build on an Apple Silicon Mac, pass --platform. Push to any registry the workers can reach: Docker Hub, GitHub Container Registry, a cloud registry, or the Apipods registry.
$ docker buildx build --platform linux/amd64 -t ghcr.io/acme/sdxl-worker:1.4.0 ./worker
$ docker push ghcr.io/acme/sdxl-worker:1.4.0latest does not trigger a rollout, and hosts may keep serving the cached image.Private registries
Store pull credentials once as a registry credential (console: Settings → Registry credentials, or the API) and reference it with registryCredentialId (for example rcr_6w2m9q4k) when you create the endpoint. Images in the Apipods registry need no credential.
Build, push and deploy in one step
apipods endpoints deploy builds the Dockerfile locally with Docker, pushes the image to the Apipods registry at registry.apipods.com/<org>/<name>:<tag> and creates the endpoint, or rolls out the new image if it already exists. Settings come from apipods.toml:
# apipods.toml — read by `apipods endpoints deploy`
[endpoint]
name = "sdxl-turbo"
gpu_pool_ids = ["L40S", "L4"]
gpu_count = 1
region_ids = ["eu-nl-1"]
max_workers = 5
idle_timeout_in_sec = 5
execution_timeout_in_sec = 600
network_volume_id = "vol_c7d2h4ke"
[endpoint.env]
MODEL_ID = "stabilityai/sdxl-turbo"
HF_HOME = "/volume/hf"
HF_TOKEN = "{{ secrets.HF_TOKEN }}"$ apipods endpoints deploy ./worker
Building registry.apipods.com/acme/sdxl-turbo:20261118-1402 (linux/amd64)... done
Pushing... done (412 MB, 3 new layers)
Updating endpoint ep_4n8wq2zt (sdxl-turbo)... done
Run URL: https://run.apipods.com/v1/ep_4n8wq2zt