Stu Mason
Stu Mason

Activity

Issue Resolved

Issue #23 closed: Move Coolify configuration from .env to database table

Problem

Currently, coolify:provision stores all Coolify resource UUIDs and configuration in .env:

COOLIFY_SERVER_UUID=ggkk8w4c08gw48oowsg4g0oc
COOLIFY_PROJECT_UUID=wkcokg8wks0k4kgokoccok0s
COOLIFY_ENVIRONMENT=production
COOLIFY_DEPLOY_KEY_UUID=p00o88gg8wgok4ckkkksko48
COOLIFY_APPLICATION_UUID=bkoss4k84woow4ow0s4ooggw
COOLIFY_DATABASE_UUID=uwcw4kgswcco4c8wko400ggc
COOLIFY_REDIS_UUID=bgcw84ock8ksc40kcs0c08o4

This approach has several limitations:

  • Not portable - config is tied to the filesystem, not the app
  • No multi-tenancy - can't manage multiple Coolify setups per app
  • No team support - can't tie into Laravel's auth/permissions
  • No audit trail - no history of configuration changes
  • Re-provisioning issues - old UUIDs persist and cause conflicts
  • Not queryable - can't easily find all apps on a specific server

Proposed Solution

Create a coolify_resources table (or similar) to store configuration:

Schema::create('coolify_resources', function (Blueprint $table) {
    $table->id();
    $table->string('name');  // Human-readable name for this config
    $table->string('server_uuid');
    $table->string('project_uuid');
    $table->string('environment')->default('production');
    $table->string('deploy_key_uuid')->nullable();
    $table->string('repository')->nullable();
    $table->string('branch')->default('main');
    $table->string('application_uuid')->nullable();
    $table->string('database_uuid')->nullable();
    $table->string('redis_uuid')->nullable();
    $table->json('metadata')->nullable();  // For extensibility
    $table->foreignId('user_id')->nullable()->constrained();  // Who created it
    $table->timestamps();
});

Benefits

  1. Multi-environment - manage staging, production, preview envs from one app
  2. Team collaboration - integrate with Spatie Permissions or Laravel's gates
  3. Audit trail - timestamps + user_id track changes
  4. Clean re-provisioning - mark old config as inactive, create new
  5. Dashboard integration - query and display all managed resources
  6. Relationship modeling - one server → many apps, etc.

Migration Path

  • Keep .env support for COOLIFY_TOKEN and COOLIFY_URL (credentials)
  • Move resource UUIDs to database
  • Add coolify:migrate-config command to migrate existing .env to database
  • Deprecate .env-based resource storage

Tasks

  • Create migration for coolify_resources table
  • Create CoolifyResource Eloquent model
  • Update ProvisionCommand to store in database
  • Update dashboard to read from database
  • Add coolify:migrate-config command
  • Update documentation

Stu Mason + AI [email protected]