Commit 7e9c109 1 parent b058fd0 commit 7e9c109 Copy full SHA for 7e9c109
File tree 5 files changed +75
-16
lines changed
5 files changed +75
-16
lines changed Original file line number Diff line number Diff line change 4
4
#
5
5
set -e
6
6
SCRIPT_DIR=" $( cd " $( dirname " ${0} " ) " && pwd) "
7
+
8
+ # source common functionalities
9
+ . " ${SCRIPT_DIR} /scripts/common.bash"
10
+
7
11
pushd " $SCRIPT_DIR "
8
12
9
13
function usage()
@@ -19,11 +23,6 @@ Options:
19
23
"
20
24
}
21
25
22
- function log()
23
- {
24
- >&2 echo " $@ "
25
- }
26
-
27
26
# Option parsing
28
27
dc_forward_params=()
29
28
while [[ $# -gt 0 ]]
88
87
log " Forwarding to docker-compose: ${dc_forward_params[@]} "
89
88
fi
90
89
91
- docker-compose \
90
+ get_docker_compose_cmd DC_CMD
91
+
92
+ " ${DC_CMD[@]} " \
92
93
--env-file " $SCRIPT_DIR " /docker/.env \
93
94
-f " $SCRIPT_DIR " /docker/docker-compose.yml \
94
95
--profile build-only \
Original file line number Diff line number Diff line change 4
4
#
5
5
set -e
6
6
SCRIPT_DIR=" $( cd " $( dirname " ${0} " ) " && pwd) "
7
+
8
+ # source common functionalities
9
+ . " ${SCRIPT_DIR} /scripts/common.bash"
10
+
7
11
pushd " $SCRIPT_DIR "
8
12
9
13
function usage()
36
40
if [[ " ${# dc_forward_params[@]} " -gt 0 ]]
37
41
then
38
42
# shellcheck disable=SC2145
39
- echo " Forwarding to docker-compose: ${dc_forward_params[@]} "
43
+ log " Forwarding to docker-compose: ${dc_forward_params[@]} "
40
44
fi
41
45
42
- docker-compose \
46
+ get_docker_compose_cmd DC_CMD
47
+
48
+ " ${DC_CMD[@]} " \
43
49
--env-file " $SCRIPT_DIR " /docker/.env \
44
50
-f " $SCRIPT_DIR " /docker/docker-compose.yml \
45
51
--profile build-only \
Original file line number Diff line number Diff line change 4
4
#
5
5
set -e
6
6
SCRIPT_DIR=" $( cd " $( dirname " ${0} " ) " && pwd) "
7
+
8
+ # source common functionalities
9
+ . " ${SCRIPT_DIR} /scripts/common.bash"
10
+
7
11
pushd " $SCRIPT_DIR "
8
12
9
13
function usage()
36
40
if [[ " ${# dc_forward_params[@]} " -gt 0 ]]
37
41
then
38
42
# shellcheck disable=SC2145
39
- echo " Forwarding to docker-compose: ${dc_forward_params[@]} "
43
+ log " Forwarding to docker-compose: ${dc_forward_params[@]} "
40
44
fi
41
45
42
- docker-compose \
46
+ get_docker_compose_cmd DC_CMD
47
+
48
+ " ${DC_CMD[@]} " \
43
49
--env-file " $SCRIPT_DIR " /docker/.env \
44
50
-f " $SCRIPT_DIR " /docker/docker-compose.yml \
45
51
--profile build-only \
Original file line number Diff line number Diff line change 5
5
set -e
6
6
SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
7
7
8
+ # source common functionalities
9
+ . " ${SCRIPT_DIR} /scripts/common.bash"
10
+
8
11
DEFAULT_SERVICE_NAME=" workspace-shell-dev-gpu"
9
12
10
13
function usage()
@@ -29,11 +32,6 @@ Options:
29
32
"
30
33
}
31
34
32
- function log()
33
- {
34
- >&2 echo " $@ "
35
- }
36
-
37
35
# Option parsing
38
36
passthrough_args=()
39
37
while [[ $# -gt 0 ]]
@@ -102,8 +100,10 @@ else
102
100
"
103
101
fi
104
102
103
+ get_docker_compose_cmd DC_CMD
104
+
105
105
set +e
106
- docker-compose \
106
+ " ${DC_CMD[@]} " \
107
107
--env-file " $ENV_FILE " \
108
108
-f " $SCRIPT_DIR " /docker/docker-compose.yml \
109
109
run --rm \
Original file line number Diff line number Diff line change
1
+ # Common functions and definitions for use in bash scripts.
2
+
3
+
4
+ # Logging function to output strings to STDERR.
5
+ function log()
6
+ {
7
+ >&2 echo " $@ "
8
+ }
9
+
10
+
11
+ # Define to a variable of the given name an array composed of the appropriate
12
+ # CLI arguments to invoke docker compose for the current system, if able at
13
+ # all.
14
+ #
15
+ # If a docker compose tool cannot be identified, this function returns code 1.
16
+ #
17
+ # This should generally be called like:
18
+ # get_docker_compose_cmd DC_CMD
19
+ # Which results in "DC_CMD" being defined as an array in the calling context,
20
+ # viewable like:
21
+ # echo "${DC_CMD[@]}"
22
+ #
23
+ function get_docker_compose_cmd()
24
+ {
25
+ EXPORT_VAR_NAME=" $1 "
26
+ if [[ -z " $EXPORT_VAR_NAME " ]]
27
+ then
28
+ log " [ERROR] No export variable name provided as the first positional argument."
29
+ return 1
30
+ fi
31
+ # Check for v1 docker-compose tool, otherwise try to make use of v2
32
+ # docker-compose plugin
33
+ if ( command -v docker-compose > /dev/null 2>&1 )
34
+ then
35
+ log " [INFO] Using v1 docker-compose python tool"
36
+ EVAL_STR=" ${EXPORT_VAR_NAME} =( docker-compose )"
37
+ elif ( docker compose > /dev/null 2>&1 )
38
+ then
39
+ log " [INFO] Using v2 docker compose plugin"
40
+ EVAL_STR=" ${EXPORT_VAR_NAME} =( docker compose )"
41
+ else
42
+ log " [ERROR] No docker compose functionality found on the system."
43
+ return 1
44
+ fi
45
+ eval " ${EVAL_STR} "
46
+ }
You can’t perform that action at this time.
0 commit comments