kopia lustrzana https://github.com/openmaptiles/openmaptiles
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
rodzic
e5a5acfa99
commit
02dcc41e1f
20
Makefile
20
Makefile
|
@ -25,13 +25,23 @@ export TPORT
|
||||||
STYLE_FILE := build/style/style.json
|
STYLE_FILE := build/style/style.json
|
||||||
STYLE_HEADER_FILE := style/style-header.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
|
# Allow a custom docker-compose project name
|
||||||
DC_PROJECT := $(or $(DC_PROJECT),$(shell (. .env; echo $${DC_PROJECT})))
|
DC_PROJECT := $(or $(DC_PROJECT),$(shell (. .env; echo $${DC_PROJECT})))
|
||||||
ifeq ($(DC_PROJECT),)
|
ifeq ($(DC_PROJECT),)
|
||||||
DC_PROJECT := $(notdir $(shell pwd))
|
DC_PROJECT := $(notdir $(shell pwd))
|
||||||
DOCKER_COMPOSE := docker-compose
|
DOCKER_COMPOSE := $(DOCKER_COMPOSE_COMMAND)
|
||||||
else
|
else
|
||||||
DOCKER_COMPOSE := docker-compose --project-name $(DC_PROJECT)
|
DOCKER_COMPOSE := $(DOCKER_COMPOSE_COMMAND) --project-name $(DC_PROJECT)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Make some operations quieter (e.g. inside the test script)
|
# 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."
|
@echo "Refreshing docker images... Use NO_REFRESH=1 to skip."
|
||||||
ifneq ($(USE_PRELOADED_IMAGE),)
|
ifneq ($(USE_PRELOADED_IMAGE),)
|
||||||
POSTGIS_IMAGE=openmaptiles/postgis-preloaded \
|
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
|
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
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -633,7 +643,7 @@ test-perf-null: init-dirs
|
||||||
|
|
||||||
.PHONY: build-test-pbf
|
.PHONY: build-test-pbf
|
||||||
build-test-pbf: init-dirs
|
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
|
.PHONY: debug
|
||||||
debug: ## Use this target when developing Makefile itself to verify loaded environment variables
|
debug: ## Use this target when developing Makefile itself to verify loaded environment variables
|
||||||
|
|
|
@ -75,13 +75,28 @@ echo " : Minimum required Docker version: $MIN_DOCKER_VER+"
|
||||||
echo " : Minimum required docker-compose version: $MIN_COMPOSE_VER+"
|
echo " : Minimum required docker-compose version: $MIN_COMPOSE_VER+"
|
||||||
echo " : See the .travis build for the currently supported versions."
|
echo " : See the .travis build for the currently supported versions."
|
||||||
echo " : Your docker system:"
|
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 --version
|
||||||
docker-compose --version
|
docker_compose_command --version
|
||||||
|
|
||||||
# based on: http://stackoverflow.com/questions/16989598/bash-comparing-version-numbers
|
# 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); }'; }
|
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
|
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!"
|
echo "ERR: Your Docker-compose version is known to have bugs, please update docker-compose!"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -116,7 +131,7 @@ echo " : Started : $STARTDATE "
|
||||||
echo " : Your bash version: $BASH_VERSION"
|
echo " : Your bash version: $BASH_VERSION"
|
||||||
echo " : Your OS : $OSTYPE"
|
echo " : Your OS : $OSTYPE"
|
||||||
docker --version
|
docker --version
|
||||||
docker-compose --version
|
docker_compose_command --version
|
||||||
|
|
||||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||||
echo " "
|
echo " "
|
||||||
|
|
Ładowanie…
Reference in New Issue