feat: resolve ${{service.<name>.fqdn}} cross-service env references#4667
Open
AlessandroCaroli wants to merge 1 commit into
Open
feat: resolve ${{service.<name>.fqdn}} cross-service env references#4667AlessandroCaroli wants to merge 1 commit into
AlessandroCaroli wants to merge 1 commit into
Conversation
Allow an application's environment variables to reference another
service's public URL within the same environment, e.g.
API_URL=${{service.backend.fqdn}}. Resolves to the referenced service's
first domain URL.
Extends the existing ${{project.*}} / ${{environment.*}} resolver in
prepareEnvironmentVariables with an optional precomputed name->fqdn map.
mechanizeDockerContainer builds that map from sibling applications and
their domains, skipping the DB lookup entirely when the env contains no
${{service.* reference. Adds tests covering resolution, composition,
multi-ref, unknown-service and no-map error cases.
Refs Dokploy#2028
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds support for referencing another service's public URL from an application's environment variables, e.g.
API_URL=${{service.backend.fqdn}}. It resolves to the referenced service's domain URL within the same environment.Why
Closes the core need in #2028 — services in a project (e.g. a frontend needing its backend's URL) currently can't reference each other's generated FQDN. This is the foundational building block both approaches discussed in the issue need.
How
Extends the existing
${{project.*}}/${{environment.*}}resolver inprepareEnvironmentVariableswith an optional precomputedname → fqdnmap.mechanizeDockerContainerbuilds that map from sibling applications + their domains, and skips the DB lookup entirely when the env has no${{service.reference. Same${{...}}syntax and error style as the existing references.Scope / notes
.fqdnto a service's first domain (https://host). Multi-domain "primary" selection and extra attributes (internal host/port) can be follow-ups.Testing
Added 6 cases to
__test__/env/environment.test.ts(resolution, composition with surrounding text, alongside project/env/self refs, unknown-service error, no-map error, no-op when absent). Full env suite green: 74/74.Refs #2028
/claim #2028
Disclosure: implemented with AI assistance (Claude), authored + verified locally by the submitter.