Skip to content

Commit

Permalink
Merge pull request #8 from GDRCD/dev
Browse files Browse the repository at this point in the history
v1.1.2
  • Loading branch information
Kasui92 authored Aug 6, 2022
2 parents bf4ff71 + 8c233df commit c6ba5a5
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions gdrcd-stack
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ set -eo pipefail
# Variables
# ---------------------------------------------------------------------

_PATH_ENV="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"/.env
_PATH_DOCKER="${_PATH_DOCKER:-$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)}"/.docker
_PATH_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
_PATH_DOCKER="$_PATH_DIR/.docker"

# If we're running in CI we need to disable TTY allocation for docker-compose
# commands that enable it by default, such as exec and run.
Expand All @@ -24,20 +24,21 @@ fi
# ---------------------------------------------------------------------

# import env file
if [[ -f "${_PATH_ENV}" ]]; then
if [[ -f "${_PATH_DIR}/.env" ]]; then
# shellcheck source=.env
source "${_PATH_ENV}"
source "${_PATH_DIR}/.env"
else
echo "Warning! No .env file found, please create one."
exit 1;
fi

# -----------------------------------------------------------------------------
# Helper functions start with _ and aren't listed in this script's help menu.
# -----------------------------------------------------------------------------

# Custom docker-compose command
function _dc {
docker-compose -p "$PROJECT" -f "$_PATH_DOCKER/docker-compose.yml" -f "$_PATH_DOCKER/docker-compose.$ENV.yml" --env-file "$_PATH_ENV" ${TTY} "$@"
_dc() {
docker-compose -p "$PROJECT" -f "$_PATH_DOCKER/docker-compose.yml" -f "$_PATH_DOCKER/docker-compose.$ENV.yml" --env-file "$_PATH_DIR/.env" ${TTY} "$@"
}

# Check non-existent arguments
Expand Down Expand Up @@ -71,34 +72,34 @@ _checkEnvironment() {
# -----------------------------------------------------------------------------

# Build the project
function build {
build() {
_dc build
}

# Remove all containers, images, and volumes associated with the project
function clean {
clean() {
_dc down --rmi all -v --remove-orphans
}

# Get an help message
function help {
help() {
printf "%s <task> [args]\n\nTasks:\n" "${0}"
compgen -A function | grep -v "^_" | cat -n
printf "\nExtended help:\n Each task has comments for general usage\n"
}

# Run the project
function start {
start() {
_dc up -d
}

# Stop the project
function stop {
stop() {
_dc stop
}

# Restart the project
function restart {
restart() {
_dc restart
}

Expand Down

0 comments on commit c6ba5a5

Please sign in to comment.