From 50eb69b8016c64af0cc003e4171e7c5b0c3ca2f0 Mon Sep 17 00:00:00 2001 From: Hoai-Thu Vuong Date: Thu, 23 Jan 2025 20:32:56 +0700 Subject: [PATCH] chore: alias to docker compose command (#1921) ## What kind of change does this PR introduce? chore: support both `docker compose` or `docker-compose` command ## What is the current behavior? no issue link ## What is the new behavior? before this commit, dev can have error if install docker-compose as plugin. After this commit, dev can run `make docker-x` without errros ## Additional context no --- Makefile | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index bfdbb2c069..7bfd8ab981 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,12 @@ ifdef RELEASE_VERSION FLAGS=-ldflags "-X github.com/supabase/auth/internal/utilities.Version=v$(RELEASE_VERSION)" -buildvcs=false endif +ifneq ($(shell docker compose version 2>/dev/null),) + DOCKER_COMPOSE=docker compose +else + DOCKER_COMPOSE=docker-compose +endif + DEV_DOCKER_COMPOSE:=docker-compose-dev.yml help: ## Show this help. @@ -62,26 +68,26 @@ generate: dev-deps go generate ./... dev: ## Run the development containers - docker-compose -f $(DEV_DOCKER_COMPOSE) up + ${DOCKER_COMPOSE} -f $(DEV_DOCKER_COMPOSE) up down: ## Shutdown the development containers # Start postgres first and apply migrations - docker-compose -f $(DEV_DOCKER_COMPOSE) down + ${DOCKER_COMPOSE} -f $(DEV_DOCKER_COMPOSE) down docker-test: ## Run the tests using the development containers - docker-compose -f $(DEV_DOCKER_COMPOSE) up -d postgres - docker-compose -f $(DEV_DOCKER_COMPOSE) run auth sh -c "make migrate_test" - docker-compose -f $(DEV_DOCKER_COMPOSE) run auth sh -c "make test" - docker-compose -f $(DEV_DOCKER_COMPOSE) down -v + ${DOCKER_COMPOSE} -f $(DEV_DOCKER_COMPOSE) up -d postgres + ${DOCKER_COMPOSE} -f $(DEV_DOCKER_COMPOSE) run auth sh -c "make migrate_test" + ${DOCKER_COMPOSE} -f $(DEV_DOCKER_COMPOSE) run auth sh -c "make test" + ${DOCKER_COMPOSE} -f $(DEV_DOCKER_COMPOSE) down -v docker-build: ## Force a full rebuild of the development containers - docker-compose -f $(DEV_DOCKER_COMPOSE) build --no-cache - docker-compose -f $(DEV_DOCKER_COMPOSE) up -d postgres - docker-compose -f $(DEV_DOCKER_COMPOSE) run auth sh -c "make migrate_dev" - docker-compose -f $(DEV_DOCKER_COMPOSE) down + ${DOCKER_COMPOSE} -f $(DEV_DOCKER_COMPOSE) build --no-cache + ${DOCKER_COMPOSE} -f $(DEV_DOCKER_COMPOSE) up -d postgres + ${DOCKER_COMPOSE} -f $(DEV_DOCKER_COMPOSE) run auth sh -c "make migrate_dev" + ${DOCKER_COMPOSE} -f $(DEV_DOCKER_COMPOSE) down docker-clean: ## Remove the development containers and volumes - docker-compose -f $(DEV_DOCKER_COMPOSE) rm -fsv + ${DOCKER_COMPOSE} -f $(DEV_DOCKER_COMPOSE) rm -fsv format: gofmt -s -w .