Mode to manage compose file and fetch docker images from registry#25
Conversation
Instead of using global variables and repeating some of the logic in subcommands, move the state into a DockerInterface object and use methods to interact with it. Makes interfacing with docker a bit more flexible, for eventual supporting of docker files outside of the executable's directory.
Implement a GetDaemonClient method that lazily initializes the daemon client, that also avoids repeating the initialization logic in modules.
Move env vars from a global to a field on the docker interface. Cleans up a bunch of `if dev` branches.
More reliable than looking for the container label, especially when multiple instances of Ghostwriter are running.
There is now a `--mode` argument at the root level, which can one of the following: * `prod` (the default): In this new mode, Ghostwriter-CLI will write an embedded docker-compose.yml file that points to the published GW images to the XDG/Windows app data directories. With this, GW-CLI no longer needs to run inside of the GW source repo, simplifying installation * `local-prod`: Equivalent to the previous default, runs the GW checkout in the exe's directory in production mode * `local-dev`: Equivalent to the `--dev` flag, runs the GW checkout in the exe's directory in development mode Currently this uses an embedded docker-compose.yml that points to GW images that I have published. Once official GW images are published, the compose file should be updated to use them.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #25 +/- ##
==========================================
- Coverage 20.26% 19.27% -0.99%
==========================================
Files 38 39 +1
Lines 1421 1971 +550
==========================================
+ Hits 288 380 +92
- Misses 1096 1524 +428
- Partials 37 67 +30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add `--pull` flag to `build` so that it also pulls containers for system managed builds
Add missing `--rm` flag to the `run` command
Remove embedded docker compose file for production mode, and instead download the `gh-cli.yml` file from the latest Ghostwriter release. Currently pointing at my fork since the main repo doesn't have a release with the file yet.
Checks the current version of ghostwriter (from the docker-compose.yml file for production or the VERSION file for local modes) with the latest available release from Github.
After running `containers up`, fetch the current and latest versions, and print an upgrade reminder message if they differ. Only check once every 24 hours to prevent excessive network requests.
Forgot to remove this when we switched GW-CLI to downloading it instead.
If `GWCLI_AUTO_CHECK_UPDATES` is set to false in the env file, the automatic update checks will be skipped. It defaults to true.
Now that the workflow that generates it has been published, switch from my fork to the main repo.
I didn't see the existing version command when I wrote check-version. Having two version commands is pointless, so merge them.
The update command will now perform the idempotent actions of install, allowing it to update an existing installation.
While `install` shouldn't be installing a docker-compose.yml using `latest`, it might happen. The downside is that changes to the docker-compose.yml file will not be applied if simply pulling from latest.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 45 out of 46 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 45 out of 46 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 45 out of 46 changed files in this pull request and generated 13 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 45 out of 46 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds and makes default a mode that writes the Ghostwriter compose file to the XDG/Windows app data directory and pull containers from the ghcr registry rather than requiring a local checkout of the Ghostwriter source.
This simplifies installation in two ways. First, administrators will only need to download the gw-cli binary rather than checking out the source. Second, since the compose file refers to pre-built images, the image building step doesn't need to run, cutting out a lot of potential issues (such as not being able to download packages).
Instead of specifying a
--devflag, a--mode=Xargument has been added, where X can be eitherprod(the default, GWCLI managed docker),local-prod(old default, local directory in prod mode) andlocal-dev(same as--dev, local directory in dev mode).This also includes a lot of refactoring around how the CLI internally manages docker and env var info, to help with managing compose projects in arbitrary directories.
The docker-compose.yml file is fetched from the Ghostwriter GitHub releases (see GhostManager/Ghostwriter#803).
This also adds update checking functionality -
compose upwill check for updates after running by default (setGWCLI_AUTO_CHECK_UPDATESto disable) and thecheck-versionsubcommand will manually do a check.installcan be used to update to the latest (or a selected) version.