Add generate-docker-compose command #60
Merged
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.
Context
An initial attempt at #59 , minimal necessary changes but possibly insufficient for full support of the described workflow.
Description
This PR implements a new CLI command,
lagrange-cli generate-docker-compose
. The code to generate the docker-compose file is moved into a separate function which the new CLI command calls directly without any usage ofexec.Command("docker", ...)
. This command can therefore be run inside a docker container along with all the other setup commands.The
deploy
command retains its current behavior of checking for docker image availability, generating the docker-compose file (via the new function), then callingdocker compose -f <file> up -d
. Operators accustomed to thedeploy
workflow do not need to change their behavior.Limitations
This change makes the workflow described in #59 possible, but potentially clunky and incomplete. In the output
docker-compose_<net>_<l2>_<key>.yml
file, the volumes are filled in as follows (e.g.):The source path
/root/.lagrange/keypass
is the path within the CLI container, but would need to be a path in the base OS. Haven't really thought about the best solution here. Hacky solution for now is to pass the file throughsed
:This works for our (Aestus's) use case as we need to pass the docker-compose file through further scripted post-processing anyway (e.g. adding docker network connections) and it's easy to throw a
sed
in there. But it certainly feels like there could be a better solution.