Laravel Sail should support multiple docker-compose files by configuring them in a dotenv file (.env
).
The line in my .env
file...
SAIL_FILES='docker-compose.yml:docker-compose-arm.yml'
The part of Sail that handles multiple sail files (I can't/shouldn't edit this)
if [ -n "$SAIL_FILES" ]; then
# Convert SAIL_FILES to an array...
SAIL_FILES=("${SAIL_FILES//:/ }")
for FILE in "${SAIL_FILES[@]}"; do
if [ -f "$FILE" ]; then
DOCKER_COMPOSE+=(-f "$FILE")
else
echo "${BOLD}Unable to find Docker Compose file: '${FILE}'${NC}" >&2
exit 1
fi
done
fi
I've tried a few different delimiters (comma, spaces, .etc). It seems simple but I can't get it to work. I can't understand how SAIL_FILES=("${SAIL_FILES//:/ }")
performs the array conversion (I'm new to Bash).
I've recreated the issue here which should simply echo each filename on a new line.
This doesn't seem to be documented anywhere on Laravel.
Thanks.
Double quoting prevents word-splitting. If you want word-splitting to happen, don't quote:
SAIL_FILES=(${SAIL_FILES//:/ })
You can also use $IFS
to split the string without substitution:
IFS=: SAIL_FILES=($SAIL_FILES)