From 6598f243c01d96ded7fc6cc7cdbd6d672238833c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 5 Jun 2018 10:14:40 +0200 Subject: [PATCH] Fix the print for the Docker compose environment --- geoportal/c2cgeoportal_geoportal/lib/lingua_extractor.py | 2 +- .../scaffolds/create/+dot+gitignore_tmpl | 2 +- .../scaffolds/create/bin/eval-templates | 5 ++++- .../+package+/{config.yaml.mako => config.yaml.tmpl} | 6 +++--- .../scaffolds/nondockercreate/+dot+gitignore_tmpl | 1 + .../scaffolds/nondockercreate/nondocker-override.mk | 1 + .../scaffolds/nondockerupdate/+dot+upgrade.yaml_tmpl | 3 +++ .../scaffolds/update/+dot+upgrade.yaml_tmpl | 3 +++ .../scaffolds/update/CONST_Makefile_tmpl | 5 +++-- .../scaffolds/update/CONST_vars.yaml_tmpl | 1 + travis/test-upgrade-convert.sh | 2 +- travis/v22-project.yaml | 1 + 12 files changed, 23 insertions(+), 9 deletions(-) rename geoportal/c2cgeoportal_geoportal/scaffolds/create/print/print-apps/+package+/{config.yaml.mako => config.yaml.tmpl} (93%) diff --git a/geoportal/c2cgeoportal_geoportal/lib/lingua_extractor.py b/geoportal/c2cgeoportal_geoportal/lib/lingua_extractor.py index 8f6a003810..c68fc59d91 100644 --- a/geoportal/c2cgeoportal_geoportal/lib/lingua_extractor.py +++ b/geoportal/c2cgeoportal_geoportal/lib/lingua_extractor.py @@ -208,7 +208,7 @@ class GeoMapfishConfigExtractor(Extractor): # pragma: no cover GeoMapfish config extractor (raster layers, and print templates) """ - extensions = [".yaml"] + extensions = [".yaml", ".tmpl"] def __call__(self, filename, options): init_region({"backend": "dogpile.cache.memory"}) diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/create/+dot+gitignore_tmpl b/geoportal/c2cgeoportal_geoportal/scaffolds/create/+dot+gitignore_tmpl index 7fc29717bf..571344ece4 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/create/+dot+gitignore_tmpl +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/create/+dot+gitignore_tmpl @@ -11,7 +11,7 @@ __pycache__/ /testdb/13-alembic-static.sql /mapcache/ /tilegeneration/config.yaml -/print/print-apps/{{package}}/config.yaml +/print/print-apps/{{package}}/config.yaml.mako /mapserver/mapserver.map.tmpl /mapserver/*.map.tmpl /mapserver/tinyows.xml diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/create/bin/eval-templates b/geoportal/c2cgeoportal_geoportal/scaffolds/create/bin/eval-templates index 22c7aa58c9..728d58115f 100755 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/create/bin/eval-templates +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/create/bin/eval-templates @@ -1,6 +1,9 @@ #!/bin/bash -e -find /etc /mapcache -name '*.tmpl' -print | while read file +export VISIBLE_WEB_HOST_RE_ESCAPED=`python -c "print(__import__('re').escape('${VISIBLE_WEB_HOST}'))"` +export VISIBLE_ENTRY_POINT_RE_ESCAPED=`python -c "print(__import__('re').escape('${VISIBLE_ENTRY_POINT}'))"` + +find /etc /mapcache /usr/local/tomcat/webapps/ -name '*.tmpl' -print | while read file do envsubst < ${file} > ${file%.tmpl} done diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/create/print/print-apps/+package+/config.yaml.mako b/geoportal/c2cgeoportal_geoportal/scaffolds/create/print/print-apps/+package+/config.yaml.tmpl similarity index 93% rename from geoportal/c2cgeoportal_geoportal/scaffolds/create/print/print-apps/+package+/config.yaml.mako rename to geoportal/c2cgeoportal_geoportal/scaffolds/create/print/print-apps/+package+/config.yaml.tmpl index a4a38c94cf..de8018d049 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/create/print/print-apps/+package+/config.yaml.mako +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/create/print/print-apps/+package+/config.yaml.tmpl @@ -49,7 +49,7 @@ templates: httpProcessors: - !mapUri mapping: - (https?)://${__import__('re').escape(host)}/(.*): "http://127.0.0.1/$2" + (https?)://${VISIBLE_WEB_HOST_RE_ESCAPED}/(.*): "http://${GEOPORTAL_INTERNAL_URL}/$2" - !forwardHeaders matchers: - !localMatch {} @@ -63,9 +63,9 @@ templates: - !restrictUris matchers: - !localMatch - pathRegex: '${entry_point}mapserv_proxy' + pathRegex: '${VISIBLE_ENTRY_POINT_RE_ESCAPED}mapserv_proxy' - !localMatch - pathRegex: '${entry_point}tiles/.*' + pathRegex: '${VISIBLE_ENTRY_POINT_RE_ESCAPED}tiles/.*' - !localMatch reject: true - !ipMatch diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/nondockercreate/+dot+gitignore_tmpl b/geoportal/c2cgeoportal_geoportal/scaffolds/nondockercreate/+dot+gitignore_tmpl index 4e5de93cde..baa7b4d9e9 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/nondockercreate/+dot+gitignore_tmpl +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/nondockercreate/+dot+gitignore_tmpl @@ -26,6 +26,7 @@ __pycache__/ /print/WEB-INF/lib/*.jar /print/WEB-INF/classes/logback.xml /print/print-apps/{{package}}/config.yaml +/print/print-apps/{{package}}/config.yaml.tmpl /mapserver/*.map /mapserver/*.map.tmpl.mako /mapserver/tinyows.xml diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/nondockercreate/nondocker-override.mk b/geoportal/c2cgeoportal_geoportal/scaffolds/nondockercreate/nondocker-override.mk index f79ca0d500..67c70e6b66 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/nondockercreate/nondocker-override.mk +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/nondockercreate/nondocker-override.mk @@ -13,6 +13,7 @@ MAPSERVER_URL ?= http://mapserver/ export MAPSERVER_URL PRINT_URL ?= http://print:8080/print/ export PRINT_URL +PRINT_CONFIG_FILE ?= print/print-apps/$(PACKAGE)/config.yaml VISIBLE_WEB_PROTOCOL ?= https VISIBLE_WEB_PORT ?= 443 diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/nondockerupdate/+dot+upgrade.yaml_tmpl b/geoportal/c2cgeoportal_geoportal/scaffolds/nondockerupdate/+dot+upgrade.yaml_tmpl index 595ace4335..45d4e8628c 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/nondockerupdate/+dot+upgrade.yaml_tmpl +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/nondockerupdate/+dot+upgrade.yaml_tmpl @@ -158,3 +158,6 @@ files_to_move: - from: geoportal/{{package}}_geoportal/static-ngeo/components/contextualdata/contextualdata.html to: geoportal/{{package}}_geoportal/static-ngeo/js/apps/contextualdata.html version: 2.3 + - from: print/print-apps/{{package}}/config.yaml.tmpl + to: print/print-apps/{{package}}/config.yaml.mako + version: 2.3 diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/update/+dot+upgrade.yaml_tmpl b/geoportal/c2cgeoportal_geoportal/scaffolds/update/+dot+upgrade.yaml_tmpl index c3fea1424e..98b443a38b 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/update/+dot+upgrade.yaml_tmpl +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/update/+dot+upgrade.yaml_tmpl @@ -195,3 +195,6 @@ files_to_move: - from: geoportal/{{package}}_geoportal/static-ngeo/components/contextualdata/contextualdata.html to: geoportal/{{package}}_geoportal/static-ngeo/js/apps/contextualdata.html version: 2.3 + - from: print/print-apps/{{package}}/config.yaml.mako + to: print/print-apps/{{package}}/config.yaml.tmpl + version: 2.3 diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/update/CONST_Makefile_tmpl b/geoportal/c2cgeoportal_geoportal/scaffolds/update/CONST_Makefile_tmpl index 233146d5a4..f1919bca1a 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/update/CONST_Makefile_tmpl +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/update/CONST_Makefile_tmpl @@ -303,7 +303,8 @@ endif # Print PRINT_BASE_DIR ?= print -I18N_SOURCE_FILES += print/print-apps/$(PACKAGE)/config.yaml +PRINT_CONFIG_FILE ?= print/print-apps/$(PACKAGE)/config.yaml.tmpl +I18N_SOURCE_FILES += $(PRINT_CONFIG_FILE) PY_FILES = $(shell find $(PACKAGE) -type f -name '*.py' -print) @@ -685,7 +686,7 @@ docker-compose-build.yaml: /build/requirements.timestamp .PHONY: docker-build-config docker-build-config: $(shell docker-required --path .) \ - print/print-apps/$(PACKAGE)/config.yaml \ + $(PRINT_CONFIG_FILE) \ $(MAPCACHE_FILE) docker build -t $(DOCKER_BASE)-config:$(DOCKER_TAG) . diff --git a/geoportal/c2cgeoportal_geoportal/scaffolds/update/CONST_vars.yaml_tmpl b/geoportal/c2cgeoportal_geoportal/scaffolds/update/CONST_vars.yaml_tmpl index 1423b2b54a..f5d61a4620 100644 --- a/geoportal/c2cgeoportal_geoportal/scaffolds/update/CONST_vars.yaml_tmpl +++ b/geoportal/c2cgeoportal_geoportal/scaffolds/update/CONST_vars.yaml_tmpl @@ -35,6 +35,7 @@ vars: PGUSER: www-data PGPASSWORD: www-data PGDATABASE: geomapfish + GEOPORTAL_INTERNAL_URL: 'http://geoportal/' db: environment: POSTGRES_DB: geomapfish diff --git a/travis/test-upgrade-convert.sh b/travis/test-upgrade-convert.sh index 829553cb9a..8c4df43468 100755 --- a/travis/test-upgrade-convert.sh +++ b/travis/test-upgrade-convert.sh @@ -127,7 +127,7 @@ then cp {CONST_create_template/,}project.yaml.mako cp {CONST_create_template/,}vars.yaml cp {CONST_create_template/,}mapserver/tinyows.xml.mako - cp {CONST_create_template/,}print/print-apps/testgeomapfish/config.yaml.mako + cp {CONST_create_template/,}print/print-apps/testgeomapfish/config.yaml.tmpl ./docker-run --env=NODE_ENV make upgrade11 if [ ! -e .UPGRADE_SUCCESS ] then diff --git a/travis/v22-project.yaml b/travis/v22-project.yaml index cfd14ee7b1..24853b37f5 100644 --- a/travis/v22-project.yaml +++ b/travis/v22-project.yaml @@ -18,6 +18,7 @@ unmanaged_files: - mapserver/mapserver\.map\.mako - mapserver/mapserver\.map\.tmpl\.mako - print/print-apps/testgeomapfish/config\.yaml\.mako + - print/print-apps/testgeomapfish/config\.yaml\.tmpl - print/print-apps/testgeomapfish/.*\.jrxml - geoportal/testgeomapfish_geoportal/locale/fr/LC_MESSAGES/testgeomapfish-client\.po - geoportal/testgeomapfish_geoportal/locale/de/LC_MESSAGES/testgeomapfish-client\.po