Skip to contents

Generates a Docker Compose specification enforcing read-only root filesystems, dropped capabilities, no-new-privileges, pinned image digests, offline environment variables, read-only model volume mounts, and air-gapped networking (network_mode: none or an internal: true network).

Usage

emit_docker_compose(
  spec,
  file = NULL,
  service_name = NULL,
  require_pinned = TRUE
)

Arguments

spec

An airgap_container_spec() object.

file

Optional file path to write the Compose YAML.

service_name

Optional Compose service name. Defaults to paste0("airgap-", gsub("[^a-z0-9]+", "-", spec$backend)).

require_pinned

Logical scalar; abort if spec$image_digest is missing. Defaults to TRUE.

Value

A character scalar containing valid Docker Compose YAML.

Examples

spec <- airgap_container_spec(
  backend = "vllm",
  image_digest = paste0("sha256:", strrep("c", 64)),
  model_dir = "/srv/models",
  model_file = "qwen2.5-7b-instruct",
  gpu = "nvidia"
)
cat(emit_docker_compose(spec))
#> # Generated by airgapllm 0.6.0
#> # Spec digest: sha256:f2fcbe0b7a1f39cfb024af7fa1ffd9def8bee11012aa391f17b0792eec0364c5
#> services:
#>   airgap-vllm:
#>     image: vllm/vllm-openai@sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
#>     read_only: yes
#>     cap_drop:
#>       - ALL
#>     security_opt:
#>       - no-new-privileges:true
#>     tmpfs:
#>       - /tmp:rw,noexec,nosuid,size=512m
#>       - /run:rw,noexec,nosuid,size=64m
#>     volumes:
#>       - /srv/models:/models:ro
#>     environment:
#>       DO_NOT_TRACK: '1'
#>       HF_DATASETS_OFFLINE: '1'
#>       HF_HUB_OFFLINE: '1'
#>       TRANSFORMERS_OFFLINE: '1'
#>     command:
#>       - --model
#>       - /models/qwen2.5-7b-instruct
#>       - --host
#>       - 127.0.0.1
#>       - --port
#>       - '8000'
#>       - --disable-log-requests
#>     restart: 'no'
#>     deploy:
#>       resources:
#>         reservations:
#>           devices:
#>             - driver: nvidia
#>               capabilities:
#>                 - gpu
#>               count: all
#>     network_mode: none