Add deployment context variables (commit_sha, environment_name)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 37.4k
- Forks
- 3k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 73
Description
What problem will this feature address?
I am using OpenTelemetry on my project and there are some specific environment variables that I would like to be available for my services but that I either:
- Cannot know ahead of time (e.g version of the service)
- Do not want to have to provide manually (e.g the Dokploy environment name)
The usage isn't limited to OTEL of course, we can easily imagine someone that wants to add the version of its project on the footer of its page.
Coming from Coolify, they expose a SOURCE_COMMIT environment variable.
Describe the solution you'd like
For now, the 2 must-have environment variables I would use are one referring to the commit that is being deployed (when such exists, of course) and the Dokploy environment the service is deployed on.
To kinda follow what I have seen done so far regarding environments variables in Dokploy, I would not force their injection as an environment variable. In addition to project and environment variables dictionaries I would add deployment dictionary. We could then access deployment.environment_name and deployment.commit_sha and use interpolation in our environment configuration.
The interpolation would be done in the same place as other interpolations are done: https://github.com/Dokploy/dokploy/blob/0f9505327f431b5f36a2e00a5761169db09d123a/packages/server/src/utils/docker/utils.ts#L259.
Describe alternatives you've considered
For the 2 examples I used
The Dokploy environment
Easy, just add it manually and this is what I am doing currently
The version (commit sha)
An alternative could be to build a docker image in my CI and provide the commit hash as an ARG to my Dockerfile. Then I push the image to a registry and trigger a deployment on Dokploy.
However, this alternative kinda defeats the purpose of using a tool like Dokploy.
Additional context
I'm ok to prepare a PR for it, would just like some maintainers to first validate the idea to I do not spend time working on it if:
- Something is already in the pipe related to this subject and I simply missed it
- This is not something that is meant to be in the scope of the project
Will you send a PR to implement it?
Yes
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/server/src/utils/docker/utils.ts around line 259, where the issue identifies the existing interpolation logic, and inspect how the project and environment dictionaries are assembled. The work is done when deployment.environment_name and deployment.commit_sha can be used through the requested interpolation when their values exist.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, typescript
- Domain
- devops
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100