Skip to content

Commit a5a73d5

Browse files
authored
Make docker compose script more extensible and allow spaces in filenames
2 parents e91eeb9 + 10f07b7 commit a5a73d5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

compose/bin/docker-compose

+17-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,23 @@ else
66
DOCKER_COMPOSE="docker-compose"
77
fi
88

9+
COMPOSE_FILES=("compose.yaml" "compose.healthcheck.yaml")
10+
11+
# If --no-dev is passed to this script, we won't load the compose.dev.yaml file,
12+
# but this argument should be removed so it isn't passed to docker compose.
913
if [ "$1" == "--no-dev" ]; then
10-
${DOCKER_COMPOSE} -f compose.yaml -f compose.healthcheck.yaml "${@:2}"
14+
# Remove the "--no-dev" argument so it isn't passed to docker compose
15+
shift 1
1116
else
12-
${DOCKER_COMPOSE} -f compose.yaml -f compose.healthcheck.yaml -f compose.dev.yaml "$@"
17+
# The "--no-dev" argument wasn't passed in, so let's load the dev config.
18+
COMPOSE_FILES+=("compose.dev.yaml")
1319
fi
20+
21+
# Loop over the list of compose files, and prefix them with -f.
22+
# This ensures paths with spaces aren't split when passed as parameters.
23+
COMPOSE_FILES_PREFIXED=()
24+
for file in "${COMPOSE_FILES[@]}"; do
25+
COMPOSE_FILES_PREFIXED+=("-f" "$file")
26+
done
27+
28+
${DOCKER_COMPOSE} "${COMPOSE_FILES_PREFIXED[@]}" "$@"

0 commit comments

Comments
 (0)