From 1472950514276bdb2961570fc72671c882a0a41c Mon Sep 17 00:00:00 2001 From: AnthonyAxenov Date: Tue, 11 Jan 2022 10:56:03 +0800 Subject: [PATCH] docomp.sh --- shell/docomp.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 shell/docomp.sh diff --git a/shell/docomp.sh b/shell/docomp.sh new file mode 100644 index 0000000..a84faf5 --- /dev/null +++ b/shell/docomp.sh @@ -0,0 +1,26 @@ +#!/bin/bash +CONTAINER="ds-php" # the name of the container in which to 'exec' something +CONFIG="docker-compose.yml" # path to compose yml file +CMD="docker-compose -f $CONFIG" # docker-compose command +APP_URL='http://localhost:8000/' + +open_browser() { + if which xdg-open > /dev/null; then + xdg-open "$1" /dev/null 2>&1 & disown + elif which gnome-open > /dev/null; then + gnome-open "$1" /dev/null 2>&1 & disown + fi +} + +case "$1" in + '' | 'help' ) echo -e "Provide one of operations: \t start, stop, up, down, restart, rebuild, open"; + echo "Otherwise all args will passed to 'docker exec -ti $CONTAINER ...'" ;; + 'open' ) open_browser $APP_URL ;; + 'up' ) $CMD up -d --build ;; # build and start containers + 'down' ) $CMD down --remove-orphans ;; # stop and remove containers + 'start' ) $CMD start ;; # start containers + 'stop' ) $CMD stop ;; # stop containers + 'restart' ) $CMD stop && $CMD start ;; # restart containers + 'rebuild' ) $CMD down --remove-orphans && $CMD up -d --build ;; # rebuild containers + * ) docker exec -ti $CONTAINER $@ # exec anything in container +esac