Skip to content

Instantly share code, notes, and snippets.

@parsapoorsh
Created December 11, 2025 12:43
Show Gist options
  • Select an option

  • Save parsapoorsh/44481de0fc45d8125bc616a0c1163f3b to your computer and use it in GitHub Desktop.

Select an option

Save parsapoorsh/44481de0fc45d8125bc616a0c1163f3b to your computer and use it in GitHub Desktop.
tiny docker compose wrapper. forwards all remaining arguments to docker compose.
#!/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