diff --git a/Makefile b/Makefile index d15d9294..857b7313 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,7 @@ bootstrap: \ build \ migrate-api \ create-api-test-db \ + create-metabase-db \ seed-oidc \ create-superuser .PHONY: bootstrap @@ -65,10 +66,14 @@ logs-api: ## display API server logs (follow mode) @$(COMPOSE) logs -f api .PHONY: logs-api -run: ## run the whole stack - $(COMPOSE) up -d +run: ## run the api server (and dependencies) + $(COMPOSE) up -d api .PHONY: run +run-all: ## run the whole stack + $(COMPOSE) up -d api keycloak metabase +.PHONY: run-all + status: ## an alias for "docker compose ps" @$(COMPOSE) ps .PHONY: status @@ -84,6 +89,11 @@ create-api-test-db: ## create API test database @$(COMPOSE) exec postgresql bash -c 'psql "postgresql://$${POSTGRES_USER}:$${POSTGRES_PASSWORD}@$${QUALICHARGE_DB_HOST}:$${QUALICHARGE_DB_PORT}/$${QUALICHARGE_TEST_DB_NAME}" -c "create extension postgis;"' || echo "Duly noted, skipping extension creation." .PHONY: create-api-test-db +create-metabase-db: ## create metabase database + @echo "Creating metabase service database…" + @$(COMPOSE) exec postgresql bash -c 'psql "postgresql://$${POSTGRES_USER}:$${POSTGRES_PASSWORD}@$${QUALICHARGE_DB_HOST}:$${QUALICHARGE_DB_PORT}/postgres" -c "create database \"$${MB_DB_DBNAME}\";"' || echo "Duly noted, skipping database creation." +.PHONY: create-metabase-db + drop-api-test-db: ## drop API test database @echo "Droping api service test database…" @$(COMPOSE) exec postgresql bash -c 'psql "postgresql://$${POSTGRES_USER}:$${POSTGRES_PASSWORD}@$${QUALICHARGE_DB_HOST}:$${QUALICHARGE_DB_PORT}/postgres" -c "drop database \"$${QUALICHARGE_TEST_DB_NAME}\";"' || echo "Duly noted, skipping database deletion." @@ -94,6 +104,11 @@ drop-api-db: ## drop API database @$(COMPOSE) exec postgresql bash -c 'psql "postgresql://$${POSTGRES_USER}:$${POSTGRES_PASSWORD}@$${QUALICHARGE_DB_HOST}:$${QUALICHARGE_DB_PORT}/postgres" -c "drop database \"$${QUALICHARGE_DB_NAME}\";"' || echo "Duly noted, skipping database deletion." .PHONY: drop-api-db +drop-metabase-db: ## drop Metabase database + @echo "Droping metabase service database…" + @$(COMPOSE) exec postgresql bash -c 'psql "postgresql://$${POSTGRES_USER}:$${POSTGRES_PASSWORD}@$${QUALICHARGE_DB_HOST}:$${QUALICHARGE_DB_PORT}/postgres" -c "drop database \"$${MB_DB_DBNAME}\";"' || echo "Duly noted, skipping database deletion." +.PHONY: drop-metabase-db + migrate-api: ## run alembic database migrations for the api service @echo "Running api service database engine…" @$(COMPOSE) up -d --wait postgresql diff --git a/docker-compose.yml b/docker-compose.yml index e27695da..bb0c48f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,7 @@ services: env_file: - env.d/postgresql - env.d/api + - env.d/metabase healthcheck: test: - "CMD-SHELL" @@ -30,7 +31,6 @@ services: - ./src/api:/app depends_on: - postgresql - - keycloak client: build: @@ -56,6 +56,20 @@ services: volumes: - ./bin/kc-init:/usr/local/bin/kc-init + metabase: + image: metabase/metabase:v0.50.5 + ports: + - 3000:3000 + env_file: + - env.d/metabase + healthcheck: + test: curl --fail -I http://localhost:3000/api/health || exit 1 + interval: 15s + timeout: 5s + retries: 5 + depends_on: + - postgresql + # -- tools dockerize: image: jwilder/dockerize diff --git a/env.d/metabase b/env.d/metabase new file mode 100644 index 00000000..dc6a8b12 --- /dev/null +++ b/env.d/metabase @@ -0,0 +1,6 @@ +MB_DB_DBNAME=metabaseappdb +MB_DB_HOST=postgresql +MB_DB_PASS=pass +MB_DB_PORT=5432 +MB_DB_TYPE=postgres +MB_DB_USER=qualicharge