Skip to content

Instantly share code, notes, and snippets.

@ragboyjr
Last active August 10, 2018 19:40
Show Gist options
  • Save ragboyjr/2d5d77e21ebc8d920ff8224575b1e4ba to your computer and use it in GitHub Desktop.
Save ragboyjr/2d5d77e21ebc8d920ff8224575b1e4ba to your computer and use it in GitHub Desktop.
Docker Compose alias for powerful configuration
#!/usr/bin/env bash
[ -z "$DC_EXECUTABLE" ] && DC_EXECUTABLE=docker-compose
[ -z "$DC_PATH" ] && DC_PATH=.:./dev/bin:./dev/docker/bin
for p in $(echo ${DC_PATH} | tr ":" " "); do
if [ -x "${p}/${DC_EXECUTABLE}" ]; then
${p}/${DC_EXECUTABLE} "$@"
exit $?
fi
done
docker-compose "$@"
#!/usr/bin/env bash
# this file exists in your repo as an executable. You could run this as ./docker-compose {args}
up() {
# run any pre up scripts
docker-compose up -d "$@"
# run any post up scripts
}
if [[ $1 =~ ^(up)$ ]]; then
$1 "${@:2}"
else
docker-compose "$@"
fi
@ragboy
Copy link

ragboy commented Aug 10, 2018

Like most programmers, you have 80% of the job done and just walk away. In order to install dc:

curl -o /usr/local/bin/dc https://gist.githubusercontent.com/ragboyjr/2d5d77e21ebc8d920ff8224575b1e4ba/raw/0b8352dbb2ab172739b73791a9724d2b6a0ffd99/dc && chmod +x /usr/local/bin/dc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment