From d4d9acb48d5726f35fae98dfe746f213fd099701 Mon Sep 17 00:00:00 2001 From: Gus Date: Tue, 14 Oct 2025 12:25:48 +0800 Subject: [PATCH 1/2] Handle docker compose fallback for CLI --- metal/makefile/app.mk | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/metal/makefile/app.mk b/metal/makefile/app.mk index 68b2e09b..c6f595ac 100644 --- a/metal/makefile/app.mk +++ b/metal/makefile/app.mk @@ -99,11 +99,22 @@ run-cli: *) printf '';; \ esac`; \ printf " DB_SECRET_DBNAME=%s\n\n" "$$DB_SECRET_DBNAME_DISPLAY" - @DB_SECRET_USERNAME="$(DB_SECRET_USERNAME)" DB_SECRET_PASSWORD="$(DB_SECRET_PASSWORD)" DB_SECRET_DBNAME="$(DB_SECRET_DBNAME)" docker compose run --rm api-runner go run ./metal/cli/main.go || { \ - status=$$?; \ - printf "\n$(RED)❌ CLI exited with status $$status.$(NC)\n"; \ - exit $$status; \ - } + @status=0; \ + if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then \ + printf "Using docker compose to run the CLI.\n"; \ + DB_SECRET_USERNAME="$(DB_SECRET_USERNAME)" DB_SECRET_PASSWORD="$(DB_SECRET_PASSWORD)" DB_SECRET_DBNAME="$(DB_SECRET_DBNAME)" docker compose run --rm api-runner go run ./metal/cli/main.go || status=$$?; \ + elif command -v docker-compose >/dev/null 2>&1; then \ + printf "Using docker-compose to run the CLI.\n"; \ + DB_SECRET_USERNAME="$(DB_SECRET_USERNAME)" DB_SECRET_PASSWORD="$(DB_SECRET_PASSWORD)" DB_SECRET_DBNAME="$(DB_SECRET_DBNAME)" docker-compose run --rm api-runner go run ./metal/cli/main.go || status=$$?; \ + else \ + printf "\n$(RED)❌ Neither 'docker compose' nor 'docker-compose' is available.$(NC)\n"; \ + printf " Install Docker Compose or run the CLI locally without containers.\n\n"; \ + exit 1; \ + fi; \ + if [ $$status -ne 0 ]; then \ + printf "\n$(RED)❌ CLI exited with status $$status.$(NC)\n"; \ + exit $$status; \ + fi run-cli-docker: make run-cli DB_SECRET_USERNAME=$(DB_SECRET_USERNAME) DB_SECRET_PASSWORD=$(DB_SECRET_PASSWORD) DB_SECRET_DBNAME=$(DB_SECRET_DBNAME) From 22ab922f818ca1930d66d101d8f2c6cec4080cca Mon Sep 17 00:00:00 2001 From: Gus Date: Tue, 14 Oct 2025 12:38:11 +0800 Subject: [PATCH 2/2] Fix make run-cli compose fallback indentation --- metal/makefile/app.mk | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/metal/makefile/app.mk b/metal/makefile/app.mk index c6f595ac..b29af9bb 100644 --- a/metal/makefile/app.mk +++ b/metal/makefile/app.mk @@ -99,22 +99,22 @@ run-cli: *) printf '';; \ esac`; \ printf " DB_SECRET_DBNAME=%s\n\n" "$$DB_SECRET_DBNAME_DISPLAY" - @status=0; \ - if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then \ - printf "Using docker compose to run the CLI.\n"; \ - DB_SECRET_USERNAME="$(DB_SECRET_USERNAME)" DB_SECRET_PASSWORD="$(DB_SECRET_PASSWORD)" DB_SECRET_DBNAME="$(DB_SECRET_DBNAME)" docker compose run --rm api-runner go run ./metal/cli/main.go || status=$$?; \ - elif command -v docker-compose >/dev/null 2>&1; then \ - printf "Using docker-compose to run the CLI.\n"; \ - DB_SECRET_USERNAME="$(DB_SECRET_USERNAME)" DB_SECRET_PASSWORD="$(DB_SECRET_PASSWORD)" DB_SECRET_DBNAME="$(DB_SECRET_DBNAME)" docker-compose run --rm api-runner go run ./metal/cli/main.go || status=$$?; \ - else \ - printf "\n$(RED)❌ Neither 'docker compose' nor 'docker-compose' is available.$(NC)\n"; \ - printf " Install Docker Compose or run the CLI locally without containers.\n\n"; \ - exit 1; \ - fi; \ - if [ $$status -ne 0 ]; then \ - printf "\n$(RED)❌ CLI exited with status $$status.$(NC)\n"; \ - exit $$status; \ - fi + @status=0; \ + if command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then \ + printf "Using docker compose to run the CLI.\n"; \ + DB_SECRET_USERNAME="$(DB_SECRET_USERNAME)" DB_SECRET_PASSWORD="$(DB_SECRET_PASSWORD)" DB_SECRET_DBNAME="$(DB_SECRET_DBNAME)" docker compose run --rm api-runner go run ./metal/cli/main.go || status=$$?; \ + elif command -v docker-compose >/dev/null 2>&1; then \ + printf "Using docker-compose to run the CLI.\n"; \ + DB_SECRET_USERNAME="$(DB_SECRET_USERNAME)" DB_SECRET_PASSWORD="$(DB_SECRET_PASSWORD)" DB_SECRET_DBNAME="$(DB_SECRET_DBNAME)" docker-compose run --rm api-runner go run ./metal/cli/main.go || status=$$?; \ + else \ + printf "\n$(RED)❌ Neither 'docker compose' nor 'docker-compose' is available.$(NC)\n"; \ + printf " Install Docker Compose or run the CLI locally without containers.\n\n"; \ + exit 1; \ + fi; \ + if [ $$status -ne 0 ]; then \ + printf "\n$(RED)❌ CLI exited with status $$status.$(NC)\n"; \ + exit $$status; \ + fi run-cli-docker: make run-cli DB_SECRET_USERNAME=$(DB_SECRET_USERNAME) DB_SECRET_PASSWORD=$(DB_SECRET_PASSWORD) DB_SECRET_DBNAME=$(DB_SECRET_DBNAME)