Skip to content
Socaity Docs

Build

apipod --build packages your service into a production Docker image — CUDA detection, layer caching, and custom Dockerfile support.

apipod --build

Run from your project root. APIPod scans requirements.txt for GPU packages (torch, tensorflow, jax) and selects the correct CUDA base image automatically.

terminal
apipod --build
terminal
Scanning requirements.txt... torch==2.3.0 detected
Recommended Base Image: runpod/pytorch:2.4.0-py3.11-cuda12.4.1-devel-ubuntu22.04
Is this correct? [Y/n] y
Generating Dockerfile...
Dockerfile created at apipod-deploy/Dockerfile
Build the application now using docker? (Tag: my-service) [Y/n] y
Running: docker build -t my-service -f apipod-deploy/Dockerfile .
...
Successfully built  sha256:a1b2c3d4
Tagged as: my-service:latest

Build Flags

FlagDefaultDescription
[FILE]Optional target Python file (e.g. apipod --build ./main.py).
--orchestratorlocalOrchestration platform: local (default) or socaity.
--computededicatedCompute type: dedicated (default) or serverless.
--providerlocalhostInfrastructure provider: localhost (default), auto, runpod, scaleway, azure.
--regionDeployment region (optional).

CUDA Base Image Detection

APIPod reads your requirements.txt and apipod.json to pick the optimal base image. The selection table below shows the mapping logic.

Detected PackageCUDA VersionBase ImageSize
torch (any)12.4runpod/pytorch:2.4.0-py3.11-cuda12.4.1-devel-ubuntu22.04~8 GB
tensorflow / onnx12.1nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04~5 GB
cuda (generic)12.1nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04~5 GB
none detectedCPUpython:3.10-slim~150 MB

Generated Dockerfile Structure

APIPod generates a multi-stage Dockerfile optimised for layer caching. System packages and Python dependencies are installed in separate cached layers so rebuilds only copy your changed code.

Dockerfile (generated)
# Stage 1 — deps (cached)
FROM runpod/pytorch:2.4.0-py3.11-cuda12.4.1-devel-ubuntu22.04 AS deps
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Stage 2 — app (rebuilt on source change)
FROM deps AS app
COPY . .
EXPOSE 8080
CMD ["python", "service.py"]

Custom Dockerfile

Drop a Dockerfile in your project root and APIPod will use it as-is instead of generating one. Keep these rules for correct operation:

  • Copy your source into /app.
  • Set WORKDIR /app.
  • Expose port 8080.
  • Use CMD ["python", "service.py"] or an equivalent entrypoint.
Dockerfile (custom)
FROM runpod/pytorch:2.4.0-py3.11-cuda12.4.1-devel-ubuntu22.04

# Install OS-level dependencies
RUN apt-get update && apt-get install -y ffmpeg && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
EXPOSE 8080
CMD ["python", "service.py"]

apipod.json Reference

apipod-deploy/apipod.json
{
  "project": {
    "name": "my-service",
    "version": "1.0.0"
  },
  "build": {
    "base_image": ""
  },
  "runtime": {
    "gpu": "A100",
    "memory_gb": 24
  },
  "queue": {
    "max_workers": 1,
    "queue_size": 500,
    "job_ttl": 3600
  }
}