@@ -9,8 +9,8 @@ set -eo pipefail
99# Variables
1010# ---------------------------------------------------------------------
1111
12- _PATH_ENV =" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd) " /.env
13- _PATH_DOCKER=" ${_PATH_DOCKER :- $(cd " $( dirname " ${BASH_SOURCE[0]} " ) " &> / dev / null && pwd)} " / .docker
12+ _PATH_DIR =" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd) "
13+ _PATH_DOCKER=" $_PATH_DIR / .docker"
1414
1515# If we're running in CI we need to disable TTY allocation for docker-compose
1616# commands that enable it by default, such as exec and run.
2424# ---------------------------------------------------------------------
2525
2626# import env file
27- if [[ -f " ${_PATH_ENV} " ]]; then
27+ if [[ -f " ${_PATH_DIR} /.env " ]]; then
2828 # shellcheck source=.env
29- source " ${_PATH_ENV} "
29+ source " ${_PATH_DIR} /.env "
3030 else
3131 echo " Warning! No .env file found, please create one."
32+ exit 1;
3233fi
3334
3435# -----------------------------------------------------------------------------
3536# Helper functions start with _ and aren't listed in this script's help menu.
3637# -----------------------------------------------------------------------------
3738
3839# Custom docker-compose command
39- function _dc {
40- docker-compose -p " $PROJECT " -f " $_PATH_DOCKER /docker-compose.yml" -f " $_PATH_DOCKER /docker-compose.$ENV .yml" --env-file " $_PATH_ENV " ${TTY} " $@ "
40+ _dc () {
41+ docker-compose -p " $PROJECT " -f " $_PATH_DOCKER /docker-compose.yml" -f " $_PATH_DOCKER /docker-compose.$ENV .yml" --env-file " $_PATH_DIR /.env " ${TTY} " $@ "
4142}
4243
4344# Check non-existent arguments
@@ -71,34 +72,34 @@ _checkEnvironment() {
7172# -----------------------------------------------------------------------------
7273
7374# Build the project
74- function build {
75+ build () {
7576 _dc build
7677}
7778
7879# Remove all containers, images, and volumes associated with the project
79- function clean {
80+ clean () {
8081 _dc down --rmi all -v --remove-orphans
8182}
8283
8384# Get an help message
84- function help {
85+ help () {
8586 printf " %s <task> [args]\n\nTasks:\n" " ${0} "
8687 compgen -A function | grep -v " ^_" | cat -n
8788 printf " \nExtended help:\n Each task has comments for general usage\n"
8889}
8990
9091# Run the project
91- function start {
92+ start () {
9293 _dc up -d
9394}
9495
9596# Stop the project
96- function stop {
97+ stop () {
9798 _dc stop
9899}
99100
100101# Restart the project
101- function restart {
102+ restart () {
102103 _dc restart
103104}
104105
0 commit comments