Skip to content
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

Add generate-docker-compose command #60

Merged
merged 1 commit into from
May 15, 2024

Conversation

austonst
Copy link
Contributor

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 of exec.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 calling docker compose -f <file> up -d. Operators accustomed to the deploy 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.):

volumes:
      ...
      - /root/.lagrange/keypass:/app/config/keystore/bls.pass
      ...

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 through sed:

sed "s/\/root\/\.lagrange/\/your\/baseOS\/path\/here/" <docker-compose_<net>_<l2>_<key>.yml >docker-compose-fix_<net>_<l2>_<key>.yml

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.

@austonst austonst requested a review from a team May 13, 2024 23:41
Copy link
Contributor

@mastereng12 mastereng12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@austonst thank you for the contribution, this change totally makes sense!

if err != nil {
return fmt.Errorf("failed to generate docker compose file: %w", err)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the docker compose file path display here?

Copy link
Contributor

@cool-develope cool-develope left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mastereng12 mastereng12 merged commit f544e6e into Lagrange-Labs:develop May 15, 2024
3 checks passed
mastereng12 added a commit that referenced this pull request May 21, 2024
* node version update (#49)

* remove main from ci (#56)

* Bump github.com/urfave/cli/v2 from 2.27.1 to 2.27.2 (#55)

Bumps [github.com/urfave/cli/v2](https://github.com/urfave/cli) from 2.27.1 to 2.27.2.
- [Release notes](https://github.com/urfave/cli/releases)
- [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md)
- [Commits](urfave/cli@v2.27.1...v2.27.2)

---
updated-dependencies:
- dependency-name: github.com/urfave/cli/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* password path (#61)

* Add generate-docker-compose command (#60)

* feat: add Arbitrum config (#62)

* add arbitrum config

* README

* update README

* update the arbitrum mainnet

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: cool-developer <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Auston Sterling <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants