Skip to content

Commit 2092e1c

Browse files
SAIL_FILE environment variable prevents using docker-compose.override.yml (#355)
* Allow use of docker-compose.override.yml with default filenames * Allow multiple docker-compose.yml files * Update sail * Update sail Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent effd276 commit 2092e1c

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

bin/sail

+26-11
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export DB_PORT=${DB_PORT:-3306}
3535
export WWWUSER=${WWWUSER:-$UID}
3636
export WWWGROUP=${WWWGROUP:-$(id -g)}
3737

38-
export SAIL_FILE=${SAIL_FILE:-"docker-compose.yml"}
38+
export SAIL_FILES=${SAIL_FILES:-""}
3939
export SAIL_SHARE_DASHBOARD=${SAIL_SHARE_DASHBOARD:-4040}
4040
export SAIL_SHARE_SERVER_HOST=${SAIL_SHARE_SERVER_HOST:-"laravel-sail.site"}
4141
export SAIL_SHARE_SERVER_PORT=${SAIL_SHARE_SERVER_PORT:-8080}
@@ -50,6 +50,26 @@ function sail_is_not_running {
5050
exit 1
5151
}
5252

53+
# Define Docker Compose command prefix...
54+
DOCKER_COMPOSE=(docker-compose)
55+
56+
if [ -n "$SAIL_FILES" ]; then
57+
# Convert SAIL_FILES to an array...
58+
SAIL_FILES=(${SAIL_FILES//:/ })
59+
60+
for FILE in "${SAIL_FILES[@]}"; do
61+
if [ -f "$FILE" ]; then
62+
DOCKER_COMPOSE+=(-f "$FILE")
63+
else
64+
echo -e "${WHITE}Unable to find Docker Compose file: '${FILE}'${NC}" >&2
65+
66+
exit 1
67+
fi
68+
done
69+
fi
70+
71+
EXEC="yes"
72+
5373
if [ -z "$SAIL_SKIP_CHECKS" ]; then
5474
# Ensure that Docker is running...
5575
if ! docker info > /dev/null 2>&1; then
@@ -59,23 +79,18 @@ if [ -z "$SAIL_SKIP_CHECKS" ]; then
5979
fi
6080

6181
# Determine if Sail is currently up...
62-
PSRESULT="$(docker-compose -f "$SAIL_FILE" ps -q)"
63-
if docker-compose -f "$SAIL_FILE" ps "$APP_SERVICE" | grep 'Exit\|exited'; then
82+
if "${DOCKER_COMPOSE[@]}" ps "$APP_SERVICE" | grep 'Exit\|exited'; then
6483
echo -e "${WHITE}Shutting down old Sail processes...${NC}" >&2
6584

66-
docker-compose -f "$SAIL_FILE" down > /dev/null 2>&1
85+
"${DOCKER_COMPOSE[@]}" down > /dev/null 2>&1
6786

6887
EXEC="no"
69-
elif [ -n "$PSRESULT" ]; then
70-
EXEC="yes"
71-
else
88+
elif [ -z "$(${DOCKER_COMPOSE[@]} ps -q)" ]; then
7289
EXEC="no"
7390
fi
74-
else
75-
EXEC="yes"
7691
fi
7792

78-
ARGS=(-f "$SAIL_FILE")
93+
ARGS=()
7994

8095
if [ $# -gt 0 ]; then
8196
# Proxy PHP commands to the "php" binary on the application container...
@@ -351,4 +366,4 @@ else
351366
fi
352367

353368
# Run Docker Compose with the defined arguments...
354-
docker-compose "${ARGS[@]}"
369+
"${DOCKER_COMPOSE[@]}" "${ARGS[@]}"

0 commit comments

Comments
 (0)