Created
November 25, 2018 05:46
-
-
Save bryanpizzillo/3e47744b93c5c39665bf586d5673d0ff to your computer and use it in GitHub Desktop.
Function for running local docker compose and keeping project name
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
| function ldock() { | |
| # Find the root of the repo. Redirect stderr as if we are not | |
| # under a repo an error will occur. | |
| REPO_ROOT=`git rev-parse --show-toplevel 2> /dev/null` | |
| if [ "$REPO_ROOT" == "" ]; then | |
| echo "You must run this command from within a git repo." | |
| return 1 | |
| fi | |
| COMPOSE_FILE="$REPO_ROOT/docker/docker-compose.yml" | |
| if [ ! -f "$COMPOSE_FILE" ]; then | |
| echo "This project does not appear to have a docker compose file." | |
| echo "Missing: docker/docker-compose.yml" | |
| return 2 | |
| fi | |
| COMPOSE_CMD=`which docker-compose` | |
| if [ "$COMPOSE_CMD" == "" ]; then | |
| echo "Cannot find docker-compose command. Make sure it is on your path." | |
| return 3 | |
| fi | |
| # Get the name of the project (repo folder) | |
| PROJECT_NAME=$(basename "$REPO_ROOT") | |
| ## TODO: Test fake compose command name for exec-shell that will | |
| ## run "docker-compose exec web -it /bin/bash" | |
| ## Run compose pointing at our config and | |
| $COMPOSE_CMD --file $COMPOSE_FILE --project-name "$PROJECT_NAME" "$@" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This might be a good use-case for using --prefer-dist in the main composer.json file, as the the repo may not be what you expect if you're in a composer repo, eg:
instead of the expected