mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-01 08:20:28 +00:00
Refactors generate_buildtime_environment_variables() to use an associative array (dictionary) approach instead of sequential push() calls. This prevents duplicate variable declarations in the buildtime.env file. **Problem:** After adding nixpacks plan variables to buildtime.env, the same variable could appear twice in the file: - Once from nixpacks plan (e.g., NIXPACKS_NODE_VERSION='22') - Once from user-defined variables (e.g., NIXPACKS_NODE_VERSION="22") This caused shell errors and undefined behavior during Docker builds. **Root Cause:** The push() method adds items sequentially without checking for duplicate keys. When a variable existed in both nixpacks plan AND user-defined vars, both would be written to the file. **Solution:** - Use associative array ($envs_dict) for automatic deduplication - Establish clear override precedence: 1. Nixpacks plan variables (lowest priority) 2. COOLIFY_* variables (medium priority) 3. SERVICE_* variables (medium priority) 4. User-defined variables (highest priority - can override everything) - Convert to collection format at the end - Add debug logging when user variables override plan variables **Benefits:** - Automatic deduplication (array keys are unique by nature) - User variables properly override nixpacks plan values - Clear, explicit precedence order - No breaking changes to existing functionality Fixes #7114 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>