From 04abafa0a7f922162debd9b4e9fd181128d073a0 Mon Sep 17 00:00:00 2001 From: Gustavo Ocanto Date: Sat, 12 Jul 2025 14:19:10 +0800 Subject: [PATCH 1/4] add db secrets to runner --- config/makefile/app.mk | 22 ++++++++++++++++++++++ docker-compose.yml | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/config/makefile/app.mk b/config/makefile/app.mk index 747664f8..df5cd70c 100644 --- a/config/makefile/app.mk +++ b/config/makefile/app.mk @@ -30,3 +30,25 @@ install-air: # https://github.com/air-verse/air @echo "Installing air ..." @go install github.com/air-verse/air@latest + +YEL := \033[0;33m +GRN := \033[0;32m +NC := \033[0m + +app-cli: + @if [ -z "$(DB_SECRET_USERNAME)" ] || [ -z "$(DB_SECRET_PASSWORD)" ] || [ -z "$(DB_SECRET_DBNAME)" ]; then \ + printf "\n$(RED)⚠️ Usage: make app-cli \n$(NC)"; \ + printf " DB_SECRET_USERNAME=/path/to/pg_username\n"; \ + printf " DB_SECRET_PASSWORD=/path/to/pg_password\n"; \ + printf " DB_SECRET_DBNAME=/path/to/pg_dbname\n\n"; \ + printf "\n------------------------------------------------------\n\n"; \ + exit 1; \ + fi; \ + printf "\n$(GREEN)🔒 Running CLI with secrets from:$(NC)\n"; \ + printf " DB_SECRET_USERNAME=$(DB_SECRET_USERNAME)\n"; \ + printf " DB_SECRET_PASSWORD=$(DB_SECRET_PASSWORD)\n"; \ + printf " DB_SECRET_DBNAME=$(DB_SECRET_DBNAME)\n\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 $(ROOT_PATH)/cli/main.go diff --git a/docker-compose.yml b/docker-compose.yml index b69d7468..6137e84e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -80,8 +80,12 @@ services: image: golang:1.24-alpine volumes: - .:/app + - ./.env:/.env:ro - go_mod_cache:/go/pkg/mod working_dir: /app + environment: + ENV_DB_HOST: api-db + ENV_DB_PORT: ${ENV_DB_PORT:-5432} networks: - oullin_net secrets: From 0f746d445c609b020bd3f2264ad7c8733a0d60ab Mon Sep 17 00:00:00 2001 From: Gustavo Ocanto Date: Sat, 12 Jul 2025 14:21:46 +0800 Subject: [PATCH 2/4] help --- Makefile | 3 ++- config/makefile/app.mk | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 0064f089..280c7585 100644 --- a/Makefile +++ b/Makefile @@ -52,7 +52,8 @@ help: @printf " $(BOLD)$(GREEN)fresh$(NC) : Clean and reset various project components (logs, build, etc.).\n" @printf " $(BOLD)$(GREEN)audit$(NC) : Run code audits and checks.\n" @printf " $(BOLD)$(GREEN)watch$(NC) : Start a file watcher process.\n" - @printf " $(BOLD)$(GREEN)format$(NC) : Automatically format code.\n\n" + @printf " $(BOLD)$(GREEN)format$(NC) : Automatically format code.\n" + @printf " $(BOLD)$(GREEN)run-cli$(NC) : Run the API's cli interface.\n\n" @printf "$(BOLD)$(BLUE)Build Commands:$(NC)\n" @printf " $(BOLD)$(GREEN)build-local$(NC) : Build the main application for development.\n" diff --git a/config/makefile/app.mk b/config/makefile/app.mk index df5cd70c..fdc17f2a 100644 --- a/config/makefile/app.mk +++ b/config/makefile/app.mk @@ -31,11 +31,7 @@ install-air: @echo "Installing air ..." @go install github.com/air-verse/air@latest -YEL := \033[0;33m -GRN := \033[0;32m -NC := \033[0m - -app-cli: +run-cli: @if [ -z "$(DB_SECRET_USERNAME)" ] || [ -z "$(DB_SECRET_PASSWORD)" ] || [ -z "$(DB_SECRET_DBNAME)" ]; then \ printf "\n$(RED)⚠️ Usage: make app-cli \n$(NC)"; \ printf " DB_SECRET_USERNAME=/path/to/pg_username\n"; \ From 3c666221079e40b2fde610036073a109af6ef9e2 Mon Sep 17 00:00:00 2001 From: Gustavo Ocanto Date: Sat, 12 Jul 2025 14:22:34 +0800 Subject: [PATCH 3/4] phony --- config/makefile/app.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/makefile/app.mk b/config/makefile/app.mk index fdc17f2a..70a88503 100644 --- a/config/makefile/app.mk +++ b/config/makefile/app.mk @@ -1,4 +1,4 @@ -.PHONY: fresh audit watch format +.PHONY: fresh audit watch format run-cli format: gofmt -w -s . From 266d0ea1186f9cb7ebce0239389c28109398d009 Mon Sep 17 00:00:00 2001 From: Gustavo Ocanto Date: Sat, 12 Jul 2025 14:32:29 +0800 Subject: [PATCH 4/4] typo --- config/makefile/app.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/makefile/app.mk b/config/makefile/app.mk index 70a88503..da7e473d 100644 --- a/config/makefile/app.mk +++ b/config/makefile/app.mk @@ -33,7 +33,7 @@ install-air: run-cli: @if [ -z "$(DB_SECRET_USERNAME)" ] || [ -z "$(DB_SECRET_PASSWORD)" ] || [ -z "$(DB_SECRET_DBNAME)" ]; then \ - printf "\n$(RED)⚠️ Usage: make app-cli \n$(NC)"; \ + printf "\n$(RED)⚠️ Usage: make run-cli \n$(NC)"; \ printf " DB_SECRET_USERNAME=/path/to/pg_username\n"; \ printf " DB_SECRET_PASSWORD=/path/to/pg_password\n"; \ printf " DB_SECRET_DBNAME=/path/to/pg_dbname\n\n"; \