Stu Mason
Stu Mason

Activity

Issue Opened

Issue #51 opened: feat: Clone environment to create staging/dev environments

Summary

Add the ability to clone an existing environment (e.g., production) to create new environments (e.g., staging, dev) with identical infrastructure stack.

Use Cases

  • Create staging environment from production for QA testing
  • Create dev environment that auto-deploys from develop branch
  • Spin up feature branch environments for PR previews

Proposed Implementation

Dashboard UI

  • "Clone Environment" button in environment switcher or dashboard
  • Modal with options:
    • Environment name (e.g., "staging")
    • Server selection
    • Git branch (e.g., "develop" for staging)
    • Domain (e.g., staging.example.com)
    • Options to include: database, cache, services

Artisan Command

php artisan coolify:clone-environment production staging \
    --branch=develop \
    --domain=staging.example.com \
    --server=xxx \
    --with-postgres \
    --with-dragonfly

Technical Details

The building blocks already exist:

  • ApplicationRepository::createPrivateDeployKey() - create app
  • DatabaseRepository::createPostgres() / createDragonfly() - create DBs
  • All accept environment_name parameter - Coolify auto-creates environment

New work needed:

  1. Clone logic - Copy app config, adjust branch/domain
  2. Env var handling - Copy from source env, adjust DATABASE_URL, REDIS_URL, APP_URL
  3. Dashboard UI - Modal for clone options
  4. API endpoint - POST /api/environments/clone

Per-Environment Deploy Strategies (Future)

Once multi-environment is working, add per-environment settings:

  • Production: Manual deploy only (click to deploy)
  • Staging: Auto-deploy on push to main
  • Dev: Auto-deploy on push to develop
  • Builds on multi-environment support added in #50