2021-05-14 15:42:19 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
yq() {
|
2022-06-27 16:05:28 +02:00
|
|
|
docker run --rm -i -v "${PWD}:/workdir" --user "$UID" mikefarah/yq:4 "$@"
|
2021-05-14 15:42:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
config() {
|
|
|
|
SERVICE="$(yq eval '.services.*.image | select(. == "sleede/fab-manager*") | path | .[-2]' docker-compose.yml)"
|
|
|
|
}
|
|
|
|
|
2022-05-23 16:29:10 +02:00
|
|
|
docker-compose()
|
|
|
|
{
|
|
|
|
if ! docker compose version 1>/dev/null 2>/dev/null
|
|
|
|
then
|
2022-05-25 09:53:25 +02:00
|
|
|
if ! command docker-compose version 1>/dev/null 2>/dev/null
|
2022-05-23 16:29:10 +02:00
|
|
|
then
|
|
|
|
echo -e "\e[91m[ ❌ ] docker-compose was not found, exiting...\e[39m" && exit 1
|
|
|
|
else
|
2022-05-25 09:53:25 +02:00
|
|
|
command docker-compose "$@"
|
2022-05-23 16:29:10 +02:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
docker compose "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-05-14 15:42:19 +02:00
|
|
|
run()
|
|
|
|
{
|
|
|
|
config
|
2021-05-17 15:25:05 +02:00
|
|
|
docker-compose exec "$SERVICE" bundle exec rails "${@:-c}" </dev/tty
|
2021-05-14 15:42:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
run "$@"
|