From 4bbdbe5499e11301e93ce142ad39bba9898370eb Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Date: Wed, 8 Nov 2023 15:05:06 +0200 Subject: [PATCH 1/2] Enable skipping teardown when using the `run-docker` Makefile target Now you can use an environment variable to tell our `run-docker` target to skip the teardown phase. It may be done as follows: ```bash export RUN_DOCKER_NO_TEARDOWN=true ``` This will result in subsequent calls to `make teardown` to skip the `docker-compose down` call at the beginning of the run. this is handy for cases where you're doing rapid development and want to keep the database changes. --- .mk/develop.mk | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.mk/develop.mk b/.mk/develop.mk index a18c05e438..d4edcb5a07 100644 --- a/.mk/develop.mk +++ b/.mk/develop.mk @@ -15,6 +15,8 @@ DOCKERARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/') +RUN_DOCKER_NO_TEARDOWN?=false + .PHONY: run-cli run-cli: ## run the CLI, needs additional arguments @go run -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)" -tags '$(BUILDTAGS)' ./cmd/cli @@ -23,15 +25,24 @@ run-cli: ## run the CLI, needs additional arguments run-server: ## run the app @go run -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)" -tags '$(BUILDTAGS)' ./cmd/server serve +.PHONY: run-docker-teardown +run-docker-teardown: +ifeq ($(RUN_DOCKER_NO_TEARDOWN),false) + @echo "Running docker-compose down" + @$(COMPOSE) down +else + @echo "Skipping docker-compose down" +endif + .PHONY: run-docker -run-docker: ## run the app under docker-compose +run-docker: run-docker-teardown ## run the app under docker-compose @echo "Running docker-compose up $(services)..." @echo "Building the minder-server image..." @# podman (at least) doesn't seem to like multi-arch images, and sometimes picks the wrong one (e.g. amd64 on arm64) @# We also need to remove the build: directives to use ko builds @# ko resolve will fill in the image: field in the compose file, but it adds a yaml document separator @sed -e '/^ *build:/d' -e 's| image: minder:latest| image: ko://github.com/stacklok/minder/cmd/server|' docker-compose.yaml | ko resolve --base-import-paths --platform linux/$(DOCKERARCH) -f - | sed 's/^--*$$//' > .resolved-compose.yaml - @$(COMPOSE) -f .resolved-compose.yaml down && $(COMPOSE) -f .resolved-compose.yaml up $(COMPOSE_ARGS) $(services) + @$(COMPOSE) -f .resolved-compose.yaml up $(COMPOSE_ARGS) $(services) @rm .resolved-compose.yaml* .PHONY: stop-docker From 6f83e33731cbd2c9e6bc48ad161e41c271830326 Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Date: Wed, 8 Nov 2023 15:10:43 +0200 Subject: [PATCH 2/2] Add comment after new target --- .mk/develop.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mk/develop.mk b/.mk/develop.mk index d4edcb5a07..f9f36022f4 100644 --- a/.mk/develop.mk +++ b/.mk/develop.mk @@ -26,7 +26,7 @@ run-server: ## run the app @go run -ldflags "-X main.version=$(shell git describe --abbrev=0 --tags)" -tags '$(BUILDTAGS)' ./cmd/server serve .PHONY: run-docker-teardown -run-docker-teardown: +run-docker-teardown: ## teardown the docker-compose environment ifeq ($(RUN_DOCKER_NO_TEARDOWN),false) @echo "Running docker-compose down" @$(COMPOSE) down