Update Makefile (#812)
- Add `download-osmfr` and `download-bbbike` targets - Port `DC_OPTS` to Windows - Use make conditions instead of shell. Also simplifies `make -n` output - Use remote Docker machine's IP, if defined, rather than `localhost` in `http://...` messages. Also applicable for Docker Toolbox for Windows. - Align texts in `make help` output - Update and bug-fix in `make remove-docker-images`
This commit is contained in:
parent
0683185717
commit
be3c96f835
93
Makefile
93
Makefile
@ -1,12 +1,14 @@
|
|||||||
# Options to run with docker and docker-compose - ensure the container is destroyed on exit
|
# Options to run with docker and docker-compose - ensure the container is destroyed on exit
|
||||||
# Containers run as the current user rather than root (so that created files are not root-owned)
|
# Containers run as the current user rather than root (so that created files are not root-owned)
|
||||||
DC_OPTS?=--rm -u $$(id -u $${USER}):$$(id -g $${USER})
|
DC_OPTS?=--rm -u $(shell id -u):$(shell id -g)
|
||||||
|
|
||||||
# Allow a custom docker-compose project name
|
# Allow a custom docker-compose project name
|
||||||
ifeq ($(strip $(DC_PROJECT)),)
|
ifeq ($(strip $(DC_PROJECT)),)
|
||||||
override DC_PROJECT:=$(notdir $(shell pwd))
|
override DC_PROJECT:=$(notdir $(shell pwd))
|
||||||
|
DOCKER_COMPOSE:= docker-compose
|
||||||
|
else
|
||||||
|
DOCKER_COMPOSE:= docker-compose --project-name $(DC_PROJECT)
|
||||||
endif
|
endif
|
||||||
DOCKER_COMPOSE:= docker-compose --project-name $(DC_PROJECT)
|
|
||||||
|
|
||||||
# Use `xargs --no-run-if-empty` flag, if supported
|
# Use `xargs --no-run-if-empty` flag, if supported
|
||||||
XARGS:=xargs $(shell xargs --no-run-if-empty </dev/null 2>/dev/null && echo --no-run-if-empty)
|
XARGS:=xargs $(shell xargs --no-run-if-empty </dev/null 2>/dev/null && echo --no-run-if-empty)
|
||||||
@ -24,6 +26,9 @@ endif
|
|||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: build/openmaptiles.tm2source/data.yml build/mapping.yaml build/tileset.sql
|
all: build/openmaptiles.tm2source/data.yml build/mapping.yaml build/tileset.sql
|
||||||
|
|
||||||
|
# Set OpenMapTiles host
|
||||||
|
OMT_HOST:=http://$(firstword $(subst :, ,$(subst tcp://,,$(DOCKER_HOST))) localhost)
|
||||||
|
|
||||||
.PHONY: help
|
.PHONY: help
|
||||||
help:
|
help:
|
||||||
@echo "=============================================================================="
|
@echo "=============================================================================="
|
||||||
@ -33,19 +38,21 @@ help:
|
|||||||
@echo " ./quickstart.sh <<your-area>> # example: ./quickstart.sh madagascar "
|
@echo " ./quickstart.sh <<your-area>> # example: ./quickstart.sh madagascar "
|
||||||
@echo " "
|
@echo " "
|
||||||
@echo "Hints for designers:"
|
@echo "Hints for designers:"
|
||||||
@echo " make start-postserve # start Postserver + Maputnik Editor [ see localhost:8088 ] "
|
@echo " make start-postserve # start Postserver + Maputnik Editor [ see $(OMT_HOST):8088 ] "
|
||||||
@echo " make start-tileserver # start klokantech/tileserver-gl [ see localhost:8080 ] "
|
@echo " make start-tileserver # start klokantech/tileserver-gl [ see $(OMT_HOST):8080 ] "
|
||||||
@echo " "
|
@echo " "
|
||||||
@echo "Hints for developers:"
|
@echo "Hints for developers:"
|
||||||
@echo " make # build source code"
|
@echo " make # build source code"
|
||||||
@echo " make list-geofabrik # list actual geofabrik OSM extracts for download"
|
@echo " make list-geofabrik # list actual geofabrik OSM extracts for download"
|
||||||
@echo " make download-geofabrik area=albania # download OSM data from geofabrik, and create config file"
|
@echo " make download-geofabrik area=albania # download OSM data from geofabrik, and create config file"
|
||||||
|
@echo " make download-osmfr area=asia/qatar # download OSM data from openstreetmap.fr, and create config file"
|
||||||
|
@echo " make download-bbike area=Amsterdam # download OSM data from bbike.org, and create config file"
|
||||||
@echo " make psql # start PostgreSQL console"
|
@echo " make psql # start PostgreSQL console"
|
||||||
@echo " make psql-list-tables # list all PostgreSQL tables"
|
@echo " make psql-list-tables # list all PostgreSQL tables"
|
||||||
@echo " make psql-vacuum-analyze # PostgreSQL: VACUUM ANALYZE"
|
@echo " make psql-vacuum-analyze # PostgreSQL: VACUUM ANALYZE"
|
||||||
@echo " make psql-analyze # PostgreSQL: ANALYZE"
|
@echo " make psql-analyze # PostgreSQL: ANALYZE"
|
||||||
@echo " make generate-qareports # generate reports [./build/qareports]"
|
@echo " make generate-qareports # generate reports [./build/qareports]"
|
||||||
@echo " make generate-devdoc # generate devdoc including graphs for all layers [./layers/...]"
|
@echo " make generate-devdoc # generate devdoc including graphs for all layers [./layers/...]"
|
||||||
@echo " make import-sql-dev # start import-sql /bin/bash terminal"
|
@echo " make import-sql-dev # start import-sql /bin/bash terminal"
|
||||||
@echo " make import-osm-dev # start import-osm /bin/bash terminal (imposm3)"
|
@echo " make import-osm-dev # start import-osm /bin/bash terminal (imposm3)"
|
||||||
@echo " make clean-docker # remove docker containers, PG data volume"
|
@echo " make clean-docker # remove docker containers, PG data volume"
|
||||||
@ -56,7 +63,7 @@ help:
|
|||||||
@echo " make pgclimb-list-views # list PostgreSQL public schema views"
|
@echo " make pgclimb-list-views # list PostgreSQL public schema views"
|
||||||
@echo " make pgclimb-list-tables # list PostgreSQL public schema tables"
|
@echo " make pgclimb-list-tables # list PostgreSQL public schema tables"
|
||||||
@echo " cat .env # list PG database and MIN_ZOOM and MAX_ZOOM information"
|
@echo " cat .env # list PG database and MIN_ZOOM and MAX_ZOOM information"
|
||||||
@echo " cat quickstart.log # backup of the last ./quickstart.sh"
|
@echo " cat quickstart.log # transcript of the last ./quickstart.sh run"
|
||||||
@echo " make help # help about available commands"
|
@echo " make help # help about available commands"
|
||||||
@echo "=============================================================================="
|
@echo "=============================================================================="
|
||||||
|
|
||||||
@ -95,28 +102,30 @@ db-start:
|
|||||||
db-stop:
|
db-stop:
|
||||||
$(DOCKER_COMPOSE) stop postgres
|
$(DOCKER_COMPOSE) stop postgres
|
||||||
|
|
||||||
.PHONY: download-geofabrik
|
OSM_SERVERS:=geofabrik osmfr bbbike
|
||||||
download-geofabrik: init-dirs
|
ALL_DOWNLOADS:=$(addprefix download-,$(OSM_SERVERS))
|
||||||
@if ! test "$(area)"; then \
|
OSM_SERVER=$(patsubst download-%,%,$@)
|
||||||
echo "" ;\
|
.PHONY: $(ALL_DOWNLOADS)
|
||||||
echo "ERROR: Unable to download an area if area is not given." ;\
|
$(ALL_DOWNLOADS): init-dirs
|
||||||
echo "Usage:" ;\
|
ifeq ($(strip $(area)),)
|
||||||
echo " make download-geofabrik area=<area-id>" ;\
|
@echo ""
|
||||||
echo "" ;\
|
@echo "ERROR: Unable to download an area if area is not given."
|
||||||
echo "Use make list-geofabrik to get a list of all available areas" ;\
|
@echo "Usage:"
|
||||||
echo "" ;\
|
@echo " make download-$(OSM_SERVER) area=<area-id>"
|
||||||
exit 1 ;\
|
@echo ""
|
||||||
else \
|
$(if $(filter %-geofabrik,$@),@echo "Use make list-geofabrik to get a list of all available areas";echo "")
|
||||||
echo "=============== download-geofabrik =======================" ;\
|
@exit 1
|
||||||
echo "Download area: $(area)" ;\
|
else
|
||||||
$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools bash -c \
|
@echo "=============== download-$(OSM_SERVER) ======================="
|
||||||
'download-osm geofabrik $(area) \
|
@echo "Download area: $(area)"
|
||||||
--minzoom $$QUICKSTART_MIN_ZOOM \
|
$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools bash -c \
|
||||||
--maxzoom $$QUICKSTART_MAX_ZOOM \
|
'download-osm $(OSM_SERVER) $(area) \
|
||||||
--make-dc /import/docker-compose-config.yml -- -d /import' ;\
|
--minzoom $$QUICKSTART_MIN_ZOOM \
|
||||||
ls -la ./data/$(area)* ;\
|
--maxzoom $$QUICKSTART_MAX_ZOOM \
|
||||||
echo " " ;\
|
--make-dc /import/docker-compose-config.yml -- -d /import'
|
||||||
fi
|
ls -la ./data/$(notdir $(area))*
|
||||||
|
@echo ""
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: psql
|
.PHONY: psql
|
||||||
psql: db-start
|
psql: db-start
|
||||||
@ -150,14 +159,12 @@ import-lakelines: db-start
|
|||||||
$(DOCKER_COMPOSE) run $(DC_OPTS) import-lakelines
|
$(DOCKER_COMPOSE) run $(DC_OPTS) import-lakelines
|
||||||
|
|
||||||
.PHONY: generate-tiles
|
.PHONY: generate-tiles
|
||||||
|
ifneq ($(wildcard data/docker-compose-config.yml),)
|
||||||
|
DC_CONFIG_TILES:=-f docker-compose.yml -f ./data/docker-compose-config.yml
|
||||||
|
endif
|
||||||
generate-tiles: init-dirs db-start all
|
generate-tiles: init-dirs db-start all
|
||||||
rm -rf data/tiles.mbtiles
|
rm -rf data/tiles.mbtiles
|
||||||
if [ -f ./data/docker-compose-config.yml ]; then \
|
$(DOCKER_COMPOSE) $(DC_CONFIG_TILES) run $(DC_OPTS) generate-vectortiles
|
||||||
$(DOCKER_COMPOSE) -f docker-compose.yml -f ./data/docker-compose-config.yml \
|
|
||||||
run $(DC_OPTS) generate-vectortiles; \
|
|
||||||
else \
|
|
||||||
$(DOCKER_COMPOSE) run $(DC_OPTS) generate-vectortiles; \
|
|
||||||
fi
|
|
||||||
$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools generate-metadata ./data/tiles.mbtiles
|
$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools generate-metadata ./data/tiles.mbtiles
|
||||||
|
|
||||||
.PHONY: start-tileserver
|
.PHONY: start-tileserver
|
||||||
@ -175,7 +182,7 @@ start-tileserver: init-dirs
|
|||||||
@echo "***********************************************************"
|
@echo "***********************************************************"
|
||||||
@echo "* "
|
@echo "* "
|
||||||
@echo "* Start klokantech/tileserver-gl "
|
@echo "* Start klokantech/tileserver-gl "
|
||||||
@echo "* ----------------------------> check localhost:8080 "
|
@echo "* ----------------------------> check $(OMT_HOST):8080 "
|
||||||
@echo "* "
|
@echo "* "
|
||||||
@echo "***********************************************************"
|
@echo "***********************************************************"
|
||||||
@echo " "
|
@echo " "
|
||||||
@ -186,7 +193,7 @@ start-postserve: db-start
|
|||||||
@echo " "
|
@echo " "
|
||||||
@echo "***********************************************************"
|
@echo "***********************************************************"
|
||||||
@echo "* "
|
@echo "* "
|
||||||
@echo "* Bring up postserve at localhost:8090"
|
@echo "* Bring up postserve at $(OMT_HOST):8090"
|
||||||
@echo "* "
|
@echo "* "
|
||||||
@echo "***********************************************************"
|
@echo "***********************************************************"
|
||||||
@echo " "
|
@echo " "
|
||||||
@ -196,8 +203,8 @@ start-postserve: db-start
|
|||||||
@echo "***********************************************************"
|
@echo "***********************************************************"
|
||||||
@echo "* "
|
@echo "* "
|
||||||
@echo "* Start maputnik/editor "
|
@echo "* Start maputnik/editor "
|
||||||
@echo "* ---> go to http://localhost:8088"
|
@echo "* ---> go to http://$(OMT_HOST):8088 "
|
||||||
@echo "* ---> set 'data source' to http://localhost:8090"
|
@echo "* ---> set 'data source' to http://$(OMT_HOST):8090"
|
||||||
@echo "* "
|
@echo "* "
|
||||||
@echo "***********************************************************"
|
@echo "***********************************************************"
|
||||||
@echo " "
|
@echo " "
|
||||||
@ -276,9 +283,9 @@ refresh-docker-images:
|
|||||||
remove-docker-images:
|
remove-docker-images:
|
||||||
@echo "Deleting all openmaptiles related docker image(s)..."
|
@echo "Deleting all openmaptiles related docker image(s)..."
|
||||||
@$(DOCKER_COMPOSE) down
|
@$(DOCKER_COMPOSE) down
|
||||||
@docker images "openmaptiles/*" | $(XARGS) docker rmi -f
|
@docker images "openmaptiles/*" -q | $(XARGS) docker rmi -f
|
||||||
@docker images "osm2vectortiles/mapbox-studio" | $(XARGS) docker rmi -f
|
@docker images "maputnik/editor" -q | $(XARGS) docker rmi -f
|
||||||
@docker images "klokantech/tileserver-gl" | $(XARGS) docker rmi -f
|
@docker images "klokantech/tileserver-gl" -q | $(XARGS) docker rmi -f
|
||||||
|
|
||||||
.PHONY: docker-unnecessary-clean
|
.PHONY: docker-unnecessary-clean
|
||||||
docker-unnecessary-clean:
|
docker-unnecessary-clean:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user