Skip to content

Commit

Permalink
Add DC script
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanmikaelian committed Sep 5, 2017
1 parent eea575f commit 748e566
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions bin/dc
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash

# Borrowed from @ggerrietts

function dc_rebuild {
docker-compose build "$@" && docker-compose stop "$@" && docker-compose up -d "$@"
}

function dc_cycle {
docker-compose stop "$@" && docker-compose up -d "$@"
}

function dc_clean {
docker rm $(docker ps -a -q)
docker rmi $(docker images -q -f dangling=true)
}

function dc_nuke {
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
}

function dc_console {
docker-compose exec "$1" /bin/bash
}

function dc_ports {
docker ps --filter name="$1" --format "{{.Names}}: {{.Ports}}"
}

if [[ $# > 0 ]]; then
case "$1" in
clean )
dc_clean
;;
console )
shift
dc_console "$@"
;;
cycle )
shift
dc_cycle "$@"
;;
nuke )
dc_nuke
;;
ports )
shift
dc_ports "$@"
;;
rebuild )
shift
dc_rebuild "$@"
;;
*)
docker-compose "$@"
;;
esac
else
docker-compose
fi

0 comments on commit 748e566

Please sign in to comment.