Created
October 1, 2020 16:36
-
-
Save tjventurini/ac9721f19320ee11eb271cd05e86c63e to your computer and use it in GitHub Desktop.
Helper for docker-composer.
This file contains 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 dc() { | |
# check if there is a docker-compose.yml or docker-compose.yaml file in the current directory | |
if [ -f "./docker-compose.yml" ] || [ -f "./docker-compose.yaml" ]; then | |
print -P "%F{green}./docker-compose.yml%f" | |
( docker-compose $* ) | |
return 0 | |
fi | |
# check if there is a docker directory with a docker-compose.yml or docker-compose.yaml in it. | |
if [ -f "./docker/docker-compose.yml" ] || [ -f "./docker/docker-compose.yaml" ]; then | |
print -P "%F{green}.docker%f" | |
( cd ./docker && docker-compose $* ) | |
return 0 | |
fi | |
# check if there is a laradock folder in the project | |
if [ -d "./laradock" ]; then | |
if [[ $(pwd) == "/home/$USER" ]]; then | |
print -P "%F{green}~/laradock%f"; | |
else | |
print -P "%F{green}./laradock%f" | |
fi | |
( cd ./laradock && docker-compose $* ) | |
return 0 | |
fi | |
# otherwise use the one from the home directory | |
if [ -d "/home/$USER/laradock" ]; then | |
print -P "%F{green}~/laradock%f" | |
( cd ~/laradock && docker-compose $* ) | |
return 0 | |
fi | |
# if none of both are available, then exit with an error | |
print -P "%F{red}Could not find a docker setup in './docker-compose.yml', './docker', './laradock' or '~/laradock' directories.%f" | |
return 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment