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 747664f8..da7e473d 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 . @@ -30,3 +30,21 @@ install-air: # https://github.com/air-verse/air @echo "Installing air ..." @go install github.com/air-verse/air@latest + +run-cli: + @if [ -z "$(DB_SECRET_USERNAME)" ] || [ -z "$(DB_SECRET_PASSWORD)" ] || [ -z "$(DB_SECRET_DBNAME)" ]; then \ + 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"; \ + 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: