Skip to content

Commit 46861ba

Browse files
authored
Support Docker Compose V2 in Makefile (#900)
Since Docker Compose is installed as a plugin in v2 the binary `docker-compose` is not always available. The makefile will use `docker compose` in that case.
1 parent 2abd8c1 commit 46861ba

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.DEFAULT_GOAL := build
22

3+
DOCKER_COMPOSE := $(if $(shell which docker-compose),docker-compose,docker compose)
4+
35
.PHONY: build
46
build:
57
go build .
@@ -11,18 +13,18 @@ docker-all: docker-env-up docker-test docker-env-down
1113

1214
.PHONY: docker-env-up
1315
docker-env-up:
14-
docker-compose -f contrib/docker-compose-for-tests.yml up -d
16+
$(DOCKER_COMPOSE) -f contrib/docker-compose-for-tests.yml up -d
1517

1618

1719
.PHONY: docker-env-down
1820
docker-env-down:
19-
docker-compose -f contrib/docker-compose-for-tests.yml down
21+
$(DOCKER_COMPOSE) -f contrib/docker-compose-for-tests.yml down
2022

2123

2224
.PHONY: docker-test
2325
docker-test:
24-
docker-compose -f contrib/docker-compose-for-tests.yml up -d
25-
docker-compose -f contrib/docker-compose-for-tests.yml run --rm tests bash -c 'make test'
26+
$(DOCKER_COMPOSE) -f contrib/docker-compose-for-tests.yml up -d
27+
$(DOCKER_COMPOSE) -f contrib/docker-compose-for-tests.yml run --rm tests bash -c 'make test'
2628

2729

2830

0 commit comments

Comments
 (0)