Created
December 11, 2025 12:43
-
-
Save parsapoorsh/44481de0fc45d8125bc616a0c1163f3b to your computer and use it in GitHub Desktop.
tiny docker compose wrapper. forwards all remaining arguments to docker compose.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| if [[ ! -d "$script_dir" ]]; then | |
| echo "Error: dir '$script_dir' does not exist" >&2 | |
| exit 1 | |
| fi | |
| usage() { | |
| echo "Usage: $0 <mode> [docker compose arguments...]" | |
| echo " will use docker-compose.\$mode.yml" | |
| exit 1 | |
| } | |
| # if at least one argument is provided | |
| if [[ $# -lt 1 ]]; then | |
| echo "Error: Missing mode argument" >&2 | |
| usage | |
| fi | |
| mode="$1" | |
| # remove the mode argument, so the rest can be passed to docker-compose | |
| shift | |
| compose_file_path="$script_dir/docker-compose.$mode.yml" | |
| if [[ ! -f "$compose_file_path" ]]; then | |
| echo "Error: File $compose_file_path not found!" >&2 | |
| exit 1 | |
| fi | |
| echo "Using $compose_file_path" | |
| exec docker compose -f "$compose_file_path" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment