-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eea575f
commit 748e566
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
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
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 | ||
|