Files
coolify/docker-compose.dev-multi.yml
T
Andras BacsaiandClaude Opus 5.5 338f1f837f feat(dev): run one isolated dev instance per git branch
Merge scripts/dev-instances into scripts/dev. Each branch gets its own
Compose project, container, volumes, port block, libvirt network, and
KVM VMs, so stop and start reuse the same data and worktrees do not
collide.

- Name instances after the branch; keep slots and APP_KEYs in the main
  checkout's .dev-instances/ so they survive worktree removal
- Reuse existing QEMU VMs instead of recreating them; add dev:qemu --fresh
- Give each instance an isolated libvirt network (10.221.<slot>.0/24)
  and VM names coolify-dev-<branch>--<profile>
- Publish per-instance browser ports and publish them with tailscale
  serve when APP_URL is a tailnet host
- Add urls, exec, logs, container, destroy, and teardown commands; run
  teardown from jean.json before Jean deletes a worktree
- Fix Reverb/terminal browser ports and the testing-host alias in the
  instance compose file
- Keep fresh worktree instances working: pre-create laravel.log, log the
  host dev:qemu call to stderr, and stop Vite from watching vendor/

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 11:55:49 +02:00

208 lines
6.6 KiB
YAML

# Development stack used by scripts/dev: one isolated Compose project per dev
# instance (git branch), with its own container names, network, volumes, and ports.
#
# ./scripts/dev start # this branch's instance (KVM or testing-host)
# ./scripts/dev urls # all instances and their ports
# ./scripts/dev stop
#
# Env: <checkout>/.env, then <main checkout>/.dev-instances/<name>.env (generated).
# Optional profiles: vite, mailpit, minio, testing-host (scripts/dev enables them).
services:
coolify:
image: coolify:dev
pull_policy: never
container_name: "${COMPOSE_PROJECT_NAME:-coolify-dev}"
build:
context: .
dockerfile: ./docker/development/Dockerfile
args:
- USER_ID=${USERID:-1000}
- GROUP_ID=${GROUPID:-1000}
ports:
- "${DEV_BIND_ADDRESS:-0.0.0.0}:${APP_PORT:-8000}:8080"
- "${DEV_BIND_ADDRESS:-0.0.0.0}:${FORWARD_PUSHER_PORT:-6001}:6001"
- "${DEV_BIND_ADDRESS:-0.0.0.0}:${FORWARD_TERMINAL_PORT:-6002}:6002"
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
AUTORUN_ENABLED: "${AUTORUN_ENABLED:-false}"
APP_NAME: "${APP_NAME:-Coolify}"
APP_URL: "${APP_URL:-http://localhost:8000}"
APP_KEY: "${APP_KEY:-}"
APP_ENV: "${APP_ENV:-local}"
APP_DEBUG: "${APP_DEBUG:-true}"
DB_CONNECTION: pgsql
DB_HOST: postgres
DB_PORT: 5432
DB_DATABASE: "${DB_DATABASE:-coolify}"
DB_USERNAME: "${DB_USERNAME:-coolify}"
DB_PASSWORD: "${DB_PASSWORD:-password}"
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: "${REDIS_PASSWORD:-null}"
COOLIFY_CONTAINER_ROLE: "${COOLIFY_CONTAINER_ROLE:-all}"
PUSHER_HOST: "${PUSHER_HOST:-}"
# Browser-facing ports must match the host-published ports of this instance.
PUSHER_PORT: "${FORWARD_PUSHER_PORT:-6001}"
TERMINAL_PORT: "${FORWARD_TERMINAL_PORT:-6002}"
PUSHER_BACKEND_PORT: 6001
PUSHER_SCHEME: "${PUSHER_SCHEME:-http}"
PUSHER_APP_ID: "${PUSHER_APP_ID:-coolify}"
PUSHER_APP_KEY: "${PUSHER_APP_KEY:-coolify}"
PUSHER_APP_SECRET: "${PUSHER_APP_SECRET:-coolify}"
BROADCAST_CONNECTION: reverb
QUEUE_CONNECTION: redis
CACHE_STORE: redis
SESSION_DRIVER: redis
# Same values as the host-side `php artisan dev:qemu` call (config/development-qemu.php).
DEVELOPMENT_QEMU_INSTANCE: "${DEVELOPMENT_QEMU_INSTANCE:-}"
DEVELOPMENT_QEMU_SLOT: "${DEVELOPMENT_QEMU_SLOT:-}"
DEVELOPMENT_QEMU_DOCKER_NETWORK: "${COMPOSE_PROJECT_NAME:-coolify-dev}"
DEVELOPMENT_QEMU_COOLIFY_CONTAINER: "${COMPOSE_PROJECT_NAME:-coolify-dev}"
healthcheck:
test: curl -sf http://127.0.0.1:8080/api/health || exit 1
interval: 5s
retries: 10
timeout: 2s
volumes:
- .:/var/www/html/:cached
- backups_data:/var/www/html/storage/app/backups
- ./docker/coolify-terminal/terminal-server.js:/terminal/terminal-server.js
- ./docker/coolify-terminal/terminal-utils.js:/terminal/terminal-utils.js
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
networks:
- coolify
postgres:
image: postgres:15-alpine
pull_policy: always
ports:
- "${DEV_BIND_ADDRESS:-0.0.0.0}:${FORWARD_DB_PORT:-5432}:5432"
environment:
POSTGRES_USER: "${DB_USERNAME:-coolify}"
POSTGRES_PASSWORD: "${DB_PASSWORD:-password}"
POSTGRES_DB: "${DB_DATABASE:-coolify}"
POSTGRES_HOST_AUTH_METHOD: "trust"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
interval: 5s
retries: 10
timeout: 2s
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- coolify
redis:
image: redis:7-alpine
pull_policy: always
ports:
- "${DEV_BIND_ADDRESS:-0.0.0.0}:${FORWARD_REDIS_PORT:-6379}:6379"
healthcheck:
test: redis-cli ping
interval: 5s
retries: 10
timeout: 2s
volumes:
- redis_data:/data
networks:
- coolify
vite:
profiles: ["vite"]
image: node:24-alpine
pull_policy: always
working_dir: /var/www/html
environment:
# Set VITE_HOST in .env to a browser-reachable IP/hostname for LAN/Tailscale access
VITE_HOST: "${VITE_HOST:-localhost}"
VITE_PORT: "${VITE_PORT:-5173}"
VITE_PROTOCOL: "${VITE_PROTOCOL:-http}"
ports:
- "${DEV_BIND_ADDRESS:-0.0.0.0}:${VITE_PORT:-5173}:${VITE_PORT:-5173}"
volumes:
- .:/var/www/html/:cached
command: sh -c "npm install && npm run dev"
networks:
- coolify
testing-host:
profiles: ["testing-host"]
image: coolify-testing-host:dev
pull_policy: never
build:
context: .
dockerfile: ./docker/testing-host/Dockerfile
init: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- coolify_data:/data/coolify
# Same path as on the Docker host, so bind mounts created through the host daemon resolve.
- coolify_data:/var/lib/docker/volumes/${COMPOSE_PROJECT_NAME:-coolify-dev}_coolify_data/_data
- backups_data:/data/coolify/backups
- postgres_data:/data/coolify/_volumes/database
- redis_data:/data/coolify/_volumes/redis
- minio_data:/data/coolify/_volumes/minio
networks:
coolify:
# Seeders use this hostname for the localhost server.
aliases:
- coolify-testing-host
mailpit:
profiles: ["mailpit"]
image: axllent/mailpit:latest
pull_policy: always
ports:
- "${DEV_BIND_ADDRESS:-0.0.0.0}:${FORWARD_MAILPIT_PORT:-1025}:1025"
- "${DEV_BIND_ADDRESS:-0.0.0.0}:${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025"
networks:
- coolify
minio:
profiles: ["minio"]
image: coollabsio/maxio:latest
pull_policy: always
ports:
- "${DEV_BIND_ADDRESS:-0.0.0.0}:${FORWARD_MINIO_PORT:-9000}:9000"
- "${DEV_BIND_ADDRESS:-0.0.0.0}:${FORWARD_MINIO_PORT_CONSOLE:-9001}:9001"
environment:
MINIO_ACCESS_KEY: "${MINIO_ACCESS_KEY:-minioadmin}"
MINIO_SECRET_KEY: "${MINIO_SECRET_KEY:-minioadmin}"
volumes:
- minio_data:/data
networks:
- coolify
minio-init:
profiles: ["minio"]
image: ghcr.io/coollabsio/mx:0.1.0
pull_policy: always
restart: "no"
depends_on:
- minio
entrypoint: >
/bin/sh -c "
until mc alias set local http://minio:9000 minioadmin minioadmin 2>/dev/null; do sleep 2; done;
mc mb local/local --ignore-existing;
"
networks:
- coolify
volumes:
backups_data:
postgres_data:
redis_data:
coolify_data:
minio_data:
networks:
coolify:
name: "${COMPOSE_PROJECT_NAME:-coolify-dev}"
driver: bridge