Support new docker compose version (#1497)

Currently the Makefile and `quickstart.sh` expect the [deprecated docker compose V1](https://docs.docker.com/compose/#compose-v2-and-the-new-docker-compose-command) syntax, `docker-compose`.
The new V2 syntax uses `docker compose` instead.
pull/1495/head
William Edmisten 2023-03-15 17:16:00 -04:00 zatwierdzone przez GitHub
rodzic e5a5acfa99
commit 02dcc41e1f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 33 dodań i 8 usunięć

Wyświetl plik

@ -25,13 +25,23 @@ export TPORT
STYLE_FILE := build/style/style.json
STYLE_HEADER_FILE := style/style-header.json
# Support newer `docker compose` syntax in addition to `docker-compose`
ifeq (, $(shell which docker-compose))
DOCKER_COMPOSE_COMMAND := docker compose
$(info Using docker compose V2 (docker compose))
else
DOCKER_COMPOSE_COMMAND := docker-compose
$(info Using docker compose V1 (docker-compose))
endif
# Allow a custom docker-compose project name
DC_PROJECT := $(or $(DC_PROJECT),$(shell (. .env; echo $${DC_PROJECT})))
ifeq ($(DC_PROJECT),)
DC_PROJECT := $(notdir $(shell pwd))
DOCKER_COMPOSE := docker-compose
DOCKER_COMPOSE := $(DOCKER_COMPOSE_COMMAND)
else
DOCKER_COMPOSE := docker-compose --project-name $(DC_PROJECT)
DOCKER_COMPOSE := $(DOCKER_COMPOSE_COMMAND) --project-name $(DC_PROJECT)
endif
# Make some operations quieter (e.g. inside the test script)
@ -606,9 +616,9 @@ else
@echo "Refreshing docker images... Use NO_REFRESH=1 to skip."
ifneq ($(USE_PRELOADED_IMAGE),)
POSTGIS_IMAGE=openmaptiles/postgis-preloaded \
docker-compose pull --ignore-pull-failures $(QUIET_FLAG) openmaptiles-tools generate-vectortiles postgres
$(DOCKER_COMPOSE_COMMAND) pull --ignore-pull-failures $(QUIET_FLAG) openmaptiles-tools generate-vectortiles postgres
else
docker-compose pull --ignore-pull-failures $(QUIET_FLAG) openmaptiles-tools generate-vectortiles postgres import-data
$(DOCKER_COMPOSE_COMMAND) pull --ignore-pull-failures $(QUIET_FLAG) openmaptiles-tools generate-vectortiles postgres import-data
endif
endif
@ -633,7 +643,7 @@ test-perf-null: init-dirs
.PHONY: build-test-pbf
build-test-pbf: init-dirs
docker-compose run $(DC_OPTS) openmaptiles-tools /tileset/.github/workflows/build-test-data.sh
$(DOCKER_COMPOSE_COMMAND) run $(DC_OPTS) openmaptiles-tools /tileset/.github/workflows/build-test-data.sh
.PHONY: debug
debug: ## Use this target when developing Makefile itself to verify loaded environment variables

Wyświetl plik

@ -75,13 +75,28 @@ echo " : Minimum required Docker version: $MIN_DOCKER_VER+"
echo " : Minimum required docker-compose version: $MIN_COMPOSE_VER+"
echo " : See the .travis build for the currently supported versions."
echo " : Your docker system:"
if ! command -v docker-compose &> /dev/null; then
DOCKER_COMPOSE_HYPHEN=false
else
DOCKER_COMPOSE_HYPHEN=true
fi
function docker_compose_command () {
if $DOCKER_COMPOSE_HYPHEN; then
docker-compose $@
else
docker compose $@
fi
}
docker --version
docker-compose --version
docker_compose_command --version
# based on: http://stackoverflow.com/questions/16989598/bash-comparing-version-numbers
function version { echo "$@" | tr -d 'v' | tr -cs '0-9.' '.' | awk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; }
COMPOSE_VER=$(docker-compose version --short)
COMPOSE_VER=$(docker_compose_command version --short)
if [ "$(version "$COMPOSE_VER")" -lt "$(version "$MIN_COMPOSE_VER")" ]; then
echo "ERR: Your Docker-compose version is known to have bugs, please update docker-compose!"
exit 1
@ -116,7 +131,7 @@ echo " : Started : $STARTDATE "
echo " : Your bash version: $BASH_VERSION"
echo " : Your OS : $OSTYPE"
docker --version
docker-compose --version
docker_compose_command --version
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo " "