-
-
Notifications
You must be signed in to change notification settings - Fork 258
feat(docker): global compose file #386
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
Open
arnesetzer
wants to merge
5
commits into
pelias:master
Choose a base branch
from
arnesetzer:feat/globalComposeFile
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
509b32d
feat: Allow the usage of a global compose file instead of one for eac…
arnesetzer 9eb05f8
feat: Remove local compose file
arnesetzer 05e8f4c
feat: Use compose -f instead of cd
arnesetzer 30d952f
feat: enable to append/overwrite the global compose file with local o…
arnesetzer d30202e
Merge remote-tracking branch 'official/master' into feat/globalCompos…
arnesetzer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,15 +17,27 @@ register 'compose' 'ps' 'list containers' compose_ps | |
| function compose_top(){ compose_exec top $@; } | ||
| register 'compose' 'top' 'display the running processes of a container' compose_top | ||
|
|
||
| # the 'docker compose' subcommand is now the recommended method of calling compose. | ||
| # if not available, we fallback to the legacy 'docker-compose' command. | ||
| function compose_exec(){ | ||
| # check whether there is a local compose file and append them to the global one. | ||
| composeFilePath="-f ../../docker-compose.yml -f ./docker-compose.yml" | ||
| export peliasRegion="projects/$(basename $(pwd))" | ||
| if [ ! -f docker-compose.yml ];then | ||
| echo "No local file. Using only global compose file." | ||
| composeFilePath="-f ../../docker-compose.yml" | ||
| fi | ||
|
|
||
| # the 'docker compose' subcommand is now the recommended method of calling compose. | ||
| # if not available, we fallback to the legacy 'docker-compose' command. | ||
| NATIVE_COMPOSE_VERSION=$(docker compose version 2> /dev/null || true) | ||
| if [ -z "$NATIVE_COMPOSE_VERSION" ]; then | ||
| docker-compose $@; | ||
| dockerComposeCommand="docker-compose" | ||
| else | ||
| docker compose $@; | ||
| dockerComposeCommand="docker compose" | ||
| fi | ||
|
|
||
| # execute the command with the compose file(s) and any additional arguments | ||
| $dockerComposeCommand $composeFilePath $@; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not that happy with the solution, since it's not very readable. However, it's the best way I could think of to avoid some code duplication. |
||
| unset $peliasRegion | ||
| } | ||
| register 'compose' 'exec' 'execute an arbitrary `docker compose` command' compose_exec | ||
|
|
||
|
|
@@ -40,4 +52,3 @@ register 'compose' 'kill' 'kill one or more `docker compose` service(s)' compose | |
|
|
||
| function compose_down(){ compose_exec down; } | ||
| register 'compose' 'down' 'stop all `docker compose` service(s)' compose_down | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
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.
what's the
peliasRegionvariable used for?My understanding is as long as we require people to
cd projects/someProject, we don't need to consider this relative path anywhere. Am I missing something?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.
We need this variable to properly mount the directories into the docker container. E.g.
docker/docker-compose.yml
Line 17 in 30d952f
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'm gonna play with this a bit, I feel like there's got to be a way to remove it, right?
I find it really surprising that docker would base the mount directories from where the
docker-compose.ymlfile is located rather than the current working directory where thedocker composecommand is run from.Let me know if you've played around with it more.
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.
Okay, looks like they do use the path relative to
docker-compose.yml, which is annoying, but presumably they have their reasons 😆I've made a few changes so will likely open my own PR so we can iterate more quickly on this.