exoframejs / exoframe

Exoframe is a self-hosted tool that allows simple one-command deployments using Docker
https://exoframejs.github.io/exoframe/
1.13k stars 56 forks source link

Allow executing docker commands directly #165

Open mxrlkn opened 5 years ago

mxrlkn commented 5 years ago

I have an existing swarm setup already running traefik. I've run into several issues deploying docker-compose.yml files. It seems exoframe works best with a fresh swarm where exoframe sets up traefik automatically.

What I'd like is a kind of simple mode where I can write a a normal compose file, define swarm specific settings like usual (deploy: labels, etc.), and have, e.q. exoframe swarmdeploy mystack basically do a docker stack deploy -c compose.yml mystack.

What I'm really missing from vanilla swarm is a cli/token setup. I don't want to open up the docker deamon port or deploy via ssh and copy my compose files over.

It's probably out of scope though for this project, and would bypass templates, recipes, traefik auto setup.

Looks like a great project for a new swarm.

yamalight commented 5 years ago

That should be possible with see minor tweaks 🤔 I can give you more details once I'm back from vacation. Can you please describe your requirements (or use case) a bit more in-depth?

mxrlkn commented 5 years ago

Use case is just to use exoframe as a "dumb" cli. being able to control docker without having to ssh in or open the docker daemon with tls. With a token system. Mainly for use with ci/cd pipelines.

Now that I think about it, it would probably make sense to just pipe commands straight to the docker cli, that way all of the docker commands would be available via exoframe without any extra custom integration.

So I could do e.q. cat docker-compose.yml | exoframe docker stack deploy -c - mystack. or exoframe docker stack ls.

Then exoframe would just append everything after exoframe docker to docker {command}, run it, and pipe the output back.

that would of course also give regular exoframe users all the native docker commands that's not implemented in exoframe. :)

yamalight commented 5 years ago

While that does sound like a pretty neat idea (quite like it actually!) - currently it'd require some additional work to implement. Current version of Exoframe uses docker API and does not rely on (or includes) docker binary at all - so that's one thing to address 🤔 I imagine there's going to be more than one edge case that would result in need for workarounds.

I will rename the ticket to reflect the feature and will try to figure out what's needed to make that work. Thanks for the suggestion!

mxrlkn commented 5 years ago

I see the problem now. Exoframe is using dockerode, which doesn't use the docker cli, only the docker API. And it also doesn't support stacks yet, which was my main problem.

The docker cli also needs to run the same version as docker on the host.

So I guess the only way to do this really, is on runtime, check the docker host version via the docker API, curl and install the correct binary from https://download.docker.com/linux/static/stable/x86_64.

then create an endpoint that execs docker {command}.

All of the above could be turned on/off via an environment variable. Maybe with a small caution 😄

It's of course a bit annoying to do it at runtime, but I don't see another way around it.

Is this something you would be open to? I could do a PR for it.

yamalight commented 5 years ago

@marktheis that sounds like a solid approach! would absolutely be open to a PR :)