Skip to content

Commit f5964db

Browse files
authored
[feature] Launch CLI using the api-runner service (#54)
2 parents deefa9e + 266d0ea commit f5964db

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ help:
5252
@printf " $(BOLD)$(GREEN)fresh$(NC) : Clean and reset various project components (logs, build, etc.).\n"
5353
@printf " $(BOLD)$(GREEN)audit$(NC) : Run code audits and checks.\n"
5454
@printf " $(BOLD)$(GREEN)watch$(NC) : Start a file watcher process.\n"
55-
@printf " $(BOLD)$(GREEN)format$(NC) : Automatically format code.\n\n"
55+
@printf " $(BOLD)$(GREEN)format$(NC) : Automatically format code.\n"
56+
@printf " $(BOLD)$(GREEN)run-cli$(NC) : Run the API's cli interface.\n\n"
5657

5758
@printf "$(BOLD)$(BLUE)Build Commands:$(NC)\n"
5859
@printf " $(BOLD)$(GREEN)build-local$(NC) : Build the main application for development.\n"

config/makefile/app.mk

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: fresh audit watch format
1+
.PHONY: fresh audit watch format run-cli
22

33
format:
44
gofmt -w -s .
@@ -30,3 +30,21 @@ install-air:
3030
# https://github.com/air-verse/air
3131
@echo "Installing air ..."
3232
@go install github.com/air-verse/air@latest
33+
34+
run-cli:
35+
@if [ -z "$(DB_SECRET_USERNAME)" ] || [ -z "$(DB_SECRET_PASSWORD)" ] || [ -z "$(DB_SECRET_DBNAME)" ]; then \
36+
printf "\n$(RED)⚠️ Usage: make run-cli \n$(NC)"; \
37+
printf " DB_SECRET_USERNAME=/path/to/pg_username\n"; \
38+
printf " DB_SECRET_PASSWORD=/path/to/pg_password\n"; \
39+
printf " DB_SECRET_DBNAME=/path/to/pg_dbname\n\n"; \
40+
printf "\n------------------------------------------------------\n\n"; \
41+
exit 1; \
42+
fi; \
43+
printf "\n$(GREEN)🔒 Running CLI with secrets from:$(NC)\n"; \
44+
printf " DB_SECRET_USERNAME=$(DB_SECRET_USERNAME)\n"; \
45+
printf " DB_SECRET_PASSWORD=$(DB_SECRET_PASSWORD)\n"; \
46+
printf " DB_SECRET_DBNAME=$(DB_SECRET_DBNAME)\n\n"; \
47+
DB_SECRET_USERNAME="$(DB_SECRET_USERNAME)" \
48+
DB_SECRET_PASSWORD="$(DB_SECRET_PASSWORD)" \
49+
DB_SECRET_DBNAME="$(DB_SECRET_DBNAME)" \
50+
docker compose run --rm api-runner go run $(ROOT_PATH)/cli/main.go

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ services:
8080
image: golang:1.24-alpine
8181
volumes:
8282
- .:/app
83+
- ./.env:/.env:ro
8384
- go_mod_cache:/go/pkg/mod
8485
working_dir: /app
86+
environment:
87+
ENV_DB_HOST: api-db
88+
ENV_DB_PORT: ${ENV_DB_PORT:-5432}
8589
networks:
8690
- oullin_net
8791
secrets:

0 commit comments

Comments
 (0)