From 0dc74c1c0591ad7515f2db9c478405b567fb9cc1 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Sun, 2 Jul 2023 00:18:24 +0530 Subject: [PATCH] feat: helper subroutines to spin up docker DB container in make --- Makefile | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 75e41d1..af67ab7 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,15 @@ +define deploy_dependencies + @-docker create --name ${db} \ + -e POSTGRES_PASSWORD=password \ + -p 5433:5432 \ + postgres + docker start ${db} +endef + +define run_migrations + cargo run --bin tests-migrate +endef + default: frontend ## Debug build cargo build @@ -19,6 +31,20 @@ dev-env: ## Download development dependencies cargo fetch yarn install + +env.db.recreate: ## Deploy dependencies + @-docker rm -f ${db} + $(call deploy_dependencies) + sleep 5 + $(call run_migrations) + +env.db: ## Deploy dependencies + $(call deploy_dependencies) + sleep 5 + $(call run_migrations) + + + doc: ## Prepare documentation cargo doc --no-deps --workspace --all-features @@ -43,7 +69,7 @@ lint: ## Lint codebase yarn lint migrate: ## Run database migrations - cargo run --bin tests-migrate + $(call run_migrations) release: frontend ## Release build cargo build --release