Files
clio/docker/develop/run
2025-12-09 18:51:56 +00:00

67 lines
1016 B
Bash
Executable File

#!/bin/bash
script_dir=$(dirname $0)
pushd $script_dir >/dev/null
function start_container {
if [ -z "$(docker ps -q -f name=clio_develop)" ]; then
docker compose up -d
fi
}
function run {
start_container
docker compose exec clio_develop "$@"
}
function stop_container {
docker compose down
}
function open_terminal {
start_container
docker compose exec clio_develop /bin/bash
}
function print_help {
cat <<EOF
run: Run a command inside the development container.
Usage:
run [options or command]
If no options are provided, the command will be executed inside the container.
Options:
-h, --help Show this help message and exit.
-t, --terminal Open a terminal inside the container.
-s, --stop Stop the container.
EOF
}
case $1 in
-h | --help)
print_help
;;
-t | --terminal)
open_terminal
;;
-s | --stop)
stop_container
;;
-*)
echo "Unknown option: $1"
print_help
;;
*)
run "$@"
;;
esac
popd >/dev/null