Skip to content

Configuration Guide

This document describes the two types of configuration in Composia: platform configuration and service configuration.

Configuration Types

Configuration TypeFileScopeDescription
Platform Configconfig.compose.yamlEntire platformDefines how Controller and Agents start
Service Configcomposia-meta.yamlIndividual serviceDefines service deployment targets and features

Platform Configuration

Full Configuration Example

yaml
controller:
  # Network configuration
  listen_addr: ":7001"
  controller_addr: "http://controller:7001"
  
  # Directory configuration
  repo_dir: "/data/repo-controller"
  state_dir: "/data/state-controller"
  log_dir: "/data/logs"
  
  # Authentication configuration
  cli_tokens:
    - name: "compose-admin"
      token: "replace-this-token"
      enabled: true
  
  # Node configuration
  nodes:
    - id: "main"
      display_name: "Main"
      enabled: true
      token: "main-agent-token"
      public_ipv4: "203.0.113.10"
    - id: "edge"
      display_name: "Edge"
      enabled: true
      token: "edge-agent-token"
  
  # Git sync configuration (optional)
  git:
    remote_url: "https://git.example.com/infra/composia.git"
    branch: "main"
    pull_interval: "30s"
    author_name: "Composia"
    author_email: "composia@example.com"
    auth:
      token_file: "/app/configs/git-token.txt"
  
  # DNS configuration (optional)
  dns:
    cloudflare:
      api_token_file: "/app/configs/cloudflare-token.txt"
  
  # Backup configuration (optional)
  rustic:
    main_nodes:
      - "main"
  
  # Secrets configuration (optional)
  secrets:
    provider: age
    identity_file: "/app/configs/age-identity.key"
    recipient_file: "/app/configs/age-recipients.txt"
    armor: true

agent:
  controller_addr: "http://controller:7001"
  node_id: "main"
  token: "main-agent-token"
  repo_dir: "/data/repo-agent"
  state_dir: "/data/state-agent"
  caddy:
    generated_dir: "/srv/caddy/generated"

Controller Configuration

Basic Configuration

ConfigurationTypeRequiredDescription
listen_addrstringYesController listen address, e.g., :7001
controller_addrstringYesAddress used by Agents and Web UI to access Controller
repo_dirstringYesGit working tree directory for storing service definitions
state_dirstringYesSQLite and runtime state directory
log_dirstringYesTask logs persistence directory

Authentication Configuration

yaml
cli_tokens:
  - name: "admin"
    token: "your-secure-token-here"
    enabled: true
  - name: "readonly"
    token: "readonly-token"
    enabled: true
FieldDescription
nameToken name for identification
tokenToken value used by Web UI and CLI
enabledWhether this token is enabled

Security Recommendations:

  • Use strong random strings as tokens
  • Use different tokens for production
  • Rotate tokens regularly

Node Configuration

yaml
nodes:
  - id: "main"
    display_name: "Main Server"
    enabled: true
    token: "main-agent-token"
    public_ipv4: "203.0.113.10"
    public_ipv6: "2001:db8::1"
FieldRequiredDescription
idYesUnique node identifier; Agent's node_id must match
display_nameNoDisplay name for Web UI
enabledNoWhether to allow this node to connect, default true
tokenYesNode authentication token
public_ipv4NoNode public IPv4 for automatic DNS records
public_ipv6NoNode public IPv6 for automatic DNS records

Git Sync Configuration (Optional)

yaml
git:
  remote_url: "https://github.com/example/composia-services.git"
  branch: "main"
  pull_interval: "30s"
  author_name: "Composia"
  author_email: "composia@example.com"
  auth:
    token_file: "/app/configs/git-token.txt"
FieldDescription
remote_urlRemote Git repository URL
branchBranch to track, default main
pull_intervalAuto-pull interval, e.g., 30s, 5m
author_nameGit committer name
author_emailGit committer email
auth.token_filePath to access token file

DNS Configuration (Optional)

yaml
dns:
  cloudflare:
    api_token_file: "/app/configs/cloudflare-token.txt"

Secrets Configuration (Optional)

yaml
secrets:
  provider: age
  identity_file: "/app/configs/age-identity.key"
  recipient_file: "/app/configs/age-recipients.txt"
  armor: true
FieldDescription
providerEncryption provider, currently only age is supported
identity_filePath to age private key file
recipient_filePath to age public key file
armorWhether to use ASCII Armor format

Agent Configuration

ConfigurationTypeRequiredDescription
controller_addrstringYesController API address
node_idstringYesNode ID, must match Controller configuration
tokenstringYesNode authentication token
repo_dirstringYesLocal service bundle directory
state_dirstringYesLocal runtime state directory
caddy.generated_dirstringNoCaddy configuration fragment output directory

Configuration Recommendations

Minimal Configuration (Single Node)

yaml
controller:
  listen_addr: ":7001"
  controller_addr: "http://controller:7001"
  repo_dir: "/data/repo-controller"
  state_dir: "/data/state-controller"
  log_dir: "/data/logs"
  cli_tokens:
    - name: "admin"
      token: "your-token"
      enabled: true
  nodes:
    - id: "main"
      display_name: "Main"
      enabled: true
      token: "main-token"

agent:
  controller_addr: "http://controller:7001"
  node_id: "main"
  token: "main-token"
  repo_dir: "/data/repo-agent"
  state_dir: "/data/state-agent"

Enable Caddy

Add to Agent configuration:

yaml
agent:
  # ... other configuration
  caddy:
    generated_dir: "/srv/caddy/generated"

Also need to deploy the Caddy infrastructure service. See Networking.

Enable Backup

Controller configuration:

yaml
controller:
  # ... other configuration
  rustic:
    main_nodes:
      - "main"

Also need to deploy the rustic infrastructure service. See Backup & Migration.

Enable DNS

Controller configuration:

yaml
controller:
  # ... other configuration
  dns:
    cloudflare:
      api_token_file: "/app/configs/cloudflare-token.txt"

See Networking for service-side DNS configuration.

Enable Git Remote Sync

Controller configuration:

yaml
controller:
  # ... other configuration
  git:
    remote_url: "https://github.com/example/composia-services.git"
    branch: "main"
    pull_interval: "30s"
    auth:
      token_file: "/app/configs/git-token.txt"

Configuration Security

Token Management

  1. Use Environment Variables (recommended for container deployment)
yaml
cli_tokens:
  - name: "admin"
    token: "${ADMIN_TOKEN}"
    enabled: true
  1. Use Docker Secrets
yaml
cli_tokens:
  - name: "admin"
    token_file: "/run/secrets/admin_token"
    enabled: true
  1. Use Read-Only Mounts
yaml
# docker-compose.yaml
volumes:
  - ./configs:/app/configs:ro

Age Key Management

bash
# Generate age key pair
age-keygen -o key.txt

# Extract public key
cat key.txt | grep "public key" > recipients.txt

# Mount to container
# key.txt as identity_file (private key)
# recipients.txt as recipient_file (public key)

Verify Configuration

Validate configuration syntax before starting:

bash
# Validate Controller configuration
go run ./cmd/composia controller -config ./configs/config.compose.yaml -validate

# Validate Agent configuration
go run ./cmd/composia agent -config ./configs/config.compose.yaml -validate

Released under the AGPL-3.0 License.