Skip to content

feat(shared-variables): add server-scoped shared environment variables#9356

Closed
andrasbacsai wants to merge 18 commits intonextfrom
pr-7764-shadow/add-shared-server-env
Closed

feat(shared-variables): add server-scoped shared environment variables#9356
andrasbacsai wants to merge 18 commits intonextfrom
pr-7764-shadow/add-shared-server-env

Conversation

@andrasbacsai
Copy link
Copy Markdown
Member

Summary

  • Adds a new server scope to shared environment variables, accessible at /shared-variables/server/{server_uuid}
  • Auto-creates predefined COOLIFY_SERVER_UUID and COOLIFY_SERVER_NAME variables for every server (new and existing via migration)
  • Variables are referenced in app/service env values using {{server.ENV_NAME}} syntax
  • Resolution uses the deployment's destination server ($this->mainServer) across all env generation paths — fixes build-server scenario where $this->server could point to the build server instead
  • Adds Server::environment_variables() relationship and getResolvedValueWithServer($server) method on EnvironmentVariable to inject server context at deployment time
  • Scopes existing shared variable relationships (Team, Project, Environment) to explicit type filter instead of implicit nullable column checks
  • Adds Server::defaultStandaloneDockerAttributes() helper to deduplicate bootstrap code
  • Exposes server variable autocomplete in env var input component for applications and services
  • Adds new Livewire components: SharedVariables\Server\Index and SharedVariables\Server\Show with normal/developer views
  • Adds feature tests for server shared variable CRUD, inline comments, and predefined var protection

Breaking Changes

  • Downgrading from this version will cause {{server.EnvName}} references to resolve literally as {{server.EnvName}} since the server scope won't exist in older code

Related to #7764

ShadowArcanist and others added 18 commits December 24, 2025 11:30
…R_UUID)

These are not visible on shared env page but user can use these variables like they use the COOLIFY_RESOURCE_UUID
Use `$this->mainServer` when resolving environment variable values across
deployment env generation (runtime, buildtime, nixpacks, args, and secrets
hash) so shared server-scoped values are applied consistently.

Also add `server_id` to `SharedEnvironmentVariable::$fillable` and normalize
the Livewire Blade file newline.
… Server

Extract duplicated inline StandaloneDocker attribute arrays in the
Server boot lifecycle into a dedicated method, eliminating repetition
between the root-server (id=0) and normal-server paths.

Also harden the shared_environment_variables migration by wrapping
DDL statements in DB::transaction() and using DROP CONSTRAINT IF EXISTS
to make the migration safely re-runnable.

Add unit test covering the extracted method to verify uuid is always
present in bootstrap attributes.
…for server variables

Allow SharedVariables Livewire components (Environment, Project, Server)
to accept UUID parameters directly via mount() instead of relying solely
on route parameters. This enables Livewire component testing without a
live route context.

Also adds comment field support when saving/updating server shared
environment variables, guards PostgreSQL-specific migration statements
from running under SQLite (test environment compatibility), and expands
the feature test suite with server shared variable scenarios including
inline comment preservation and update behaviour.
@andrasbacsai
Copy link
Copy Markdown
Member Author

created by mistake oops

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants