-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add Docker Swarm support as a new deployment package #602
feat: add Docker Swarm support as a new deployment package #602
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Asher, thanks for contributing to Distr!! 🚀
I think the idea of supporting docker swarm deployments is great, however I have some concerns regarding the implementation at hand:
At a glance, it appears that there is a lot of overlap with the already existing docker compose agent. Only the code in docker_actions.go
appears genuinely new. For this reason and because docker stack deploy
seems like just another "mode" of docker deployment similar to docker compose, I think it would be preferable to have one agent support both and toggle between them using a new property in the agent resource response. A user could then decide between compose and swarm when creating a deployment target. Currently, I don't think there is a way for a user to use this feature so some kind support in the UI/backend would be needed in any case.
Also, we'd be happy to learn more about your use-case in order to fully understand the requirements here. 🙂
func replaceEnvVars(composeData []byte, envVars map[string]string) []byte { | ||
content := string(composeData) | ||
for key, value := range envVars { | ||
placeholder := fmt.Sprintf("${%s}", key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing the env file and replacing variables like this seems kind of brittle. I think understand that docker stack
doesn't support variable substitution directly, but a better way appears to be using docker compose config
to perform variable substitution and other generators and run docker stack deploy
with the output of that (source). Do you think that would work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, let me look into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I previously used this script, and it was incredibly helpful for managing env files with Docker Swarm. I just implemented it.
start_with_env_file() {
stack=${1:-${PWD##*/}} # by default, the name of the cointaining folder
compose_file=${2:-docker-compose.yml}
if [ ! -f $compose_file ]; then
echo "Misses compose file: $compose_file" >&2
return 1
fi
# execute as a subcommand in order to avoid the variables remain set
(
# export variables excluding comments
[ -f .env ] && export $(sed '/^#/d' .env)
# Use dsd your_stack your_compose_file to override the defaults
docker stack deploy --compose-file $compose_file "home"
)
}
Hi @asherAbecasiss thanks again for creating this PR. I quickly wanted to check in if you got docker swarm support working locally by building and re-tagging your docker-swarm agent. In order for us to implement docker swarm (stack deploy) support into Distr, we would make a bigger refactoring of the pr and implementing the changes into the existing docker agent and adding the necessary changes in the UI and database to support docker swarm deployments nativley. Let us know how your tests have been and if it make sense for us to build docker swarm support into upstream or you are happy with maintaining your fork with your custom agent. I also created a discusion (#609) and shared it on Discord to see if anyone else is interested in Docker swarm support. |
Hi @pmig , Thanks for reviewing the PR and for the follow-up! Yes, I was able to get Docker Swarm support working locally by building and re-tagging the Docker Swarm agent. The deployment process worked as expected, and I validated the stack deployment behavior in a Swarm environment. I understand that integrating Docker Swarm support into Distr would require a broader refactoring to align with the existing Docker agent, UI, and database structure. If there is interest in upstream support, I’d be happy to collaborate and adjust the implementation accordingly. |
The needed steps would be:
Let us know if you have any further questions. We are also able to assist you anytime or take over the PR if you run out of time :-) |
closed in favor of: #645 |
This PR introduces a new Docker Swarm deployment package alongside the existing Docker Compose deployment.
The Swarm package enables running services in a Swarm cluster while keeping the current Compose-based workflow intact.