Skip to content

Commit

Permalink
🔧(project) add metabase service in development environment
Browse files Browse the repository at this point in the history
We need a playground for calculated metrics dataviz.
  • Loading branch information
jmaupetit committed Jun 17, 2024
1 parent 32d1f67 commit d173948
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ bootstrap: \
build \
migrate-api \
create-api-test-db \
create-metabase-db \
seed-oidc \
create-superuser
.PHONY: bootstrap
Expand Down Expand Up @@ -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
Expand All @@ -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."
Expand All @@ -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
Expand Down
16 changes: 15 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ services:
env_file:
- env.d/postgresql
- env.d/api
- env.d/metabase
healthcheck:
test:
- "CMD-SHELL"
Expand All @@ -30,7 +31,6 @@ services:
- ./src/api:/app
depends_on:
- postgresql
- keycloak

client:
build:
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions env.d/metabase
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d173948

Please sign in to comment.