2
0

docker-compose 902 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bash
  2. if docker compose version > /dev/null 2>&1; then
  3. DOCKER_COMPOSE="docker compose"
  4. else
  5. DOCKER_COMPOSE="docker-compose"
  6. fi
  7. COMPOSE_FILES=("compose.yaml" "compose.healthcheck.yaml")
  8. # If --no-dev is passed to this script, we won't load the compose.dev.yaml file,
  9. # but this argument should be removed so it isn't passed to docker compose.
  10. if [ "$1" == "--no-dev" ]; then
  11. # Remove the "--no-dev" argument so it isn't passed to docker compose
  12. shift 1
  13. else
  14. # The "--no-dev" argument wasn't passed in, so let's load the dev config.
  15. COMPOSE_FILES+=("compose.dev.yaml")
  16. fi
  17. # Loop over the list of compose files, and prefix them with -f.
  18. # This ensures paths with spaces aren't split when passed as parameters.
  19. COMPOSE_FILES_PREFIXED=()
  20. for file in "${COMPOSE_FILES[@]}"; do
  21. COMPOSE_FILES_PREFIXED+=("-f" "$file")
  22. done
  23. ${DOCKER_COMPOSE} "${COMPOSE_FILES_PREFIXED[@]}" "$@"