Skip to content

Commit

Permalink
Be able to get the local and S3 tile in Docker compose mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jun 7, 2018
1 parent 0f98006 commit d71d8f5
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 104 deletions.
3 changes: 1 addition & 2 deletions doc/integrator/https.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ for all url except for some parameters that should always use http (actually
all request on localhost): *url* parameter in tilegeneration configuration.

If you apply ssl encryption on your application, you should take care of the
tiles url to use https scheme to avoid secure and insecure contents: change
*tiles_url* in the vars_xxx.yaml file.
tiles url to use https scheme to avoid secure and insecure contents.

Finally, you should redirect all http request to https scheme. On Camptocamp's
server, this should be asked to our sysadmin team.
Expand Down
83 changes: 0 additions & 83 deletions doc/integrator/tilegeneration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,86 +190,3 @@ using the command:
export AWS_SECRET_ACCESS_KEY=YYYY

If you forget it you will get an explicit message.

Integration in c2cgeoportal
~~~~~~~~~~~~~~~~~~~~~~~~~~~

In the ``viewer.js``, ``api/viewer.js`` and ``edit.js``:

* Be sure that ``OpenLayers.IMAGE_RELOAD_ATTEMPTS`` is not defined.
* In ``WMTS_OPTION`` url should be ${tiles_url}.

In the ``vars_<project>.yaml`` define ``tiles_url`` to something like, for S3 usage:

.. code:: yaml
tiles_url:
- http://a.tiles.{host}/
- http://b.tiles.{host}/
- http://c.tiles.{host}/
- http://d.tiles.{host}/
The configuration of the ``tiles`` vhost will be done by the sysadmins.

To get your tiles URL in the ``viewer.js`` do:

.. code:: javascript
<%
from json import dumps
%>
var WMTS_OPTIONS = {
url: ${dumps(request.registry.settings['tiles_url']) | n},
...
}
And in the ``mobile/config.js`` do:

.. code:: javascript
var dummy = "<% from json import dumps %>";
jsonFormat = new OpenLayers.Format.JSON();
try {
App.tilesURL = jsonFormat.read('${dumps(request.registry.settings["tiles_url"]) | n}');
}
catch (e) {
App.tilesURL = "";
}
var WMTS_OPTIONS = {
url: App.tilesURL,
...
}
SwitchableWMTS
--------------

Useful tool to switch from TileCloud to MapCache.

See: https://github.com/camptocamp/cgxp/blob/master/openlayers.addins/SwitchableWMTS/lib/OpenLayers/Layer/SwitchableWMTS.js

Internal service
----------------

If you use an internal service to access to the tiles you can use sub domaine
to access to them by using that in ``WMTS_OPTION``:

.. code:: javascript
url: [
'${request.route_url('<view>', subdomain='s1')}',
'${request.route_url('<view>', subdomain='s2')}',
'${request.route_url('<view>', subdomain='s3')}',
'${request.route_url('<view>', subdomain='s4')}'
]
With ``<view>`` the name of the view that serve the tiles.
The sub domain should obviously be define in the DNS and in the Apache
vhost. If the application is served on deferent URL and you want to use
the sub domain on only one of them you can define in the ``vars_<project>.yaml``
the following:

.. code:: yaml
# The URL template used to generate the sub domain URL
# %(sub)s will be replaced by the sub domain value.
subdomain_url_template: http://%(sub)s.{host}
2 changes: 1 addition & 1 deletion docker/build/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Sphinx==1.7.2 # doc
sphinx-prompt==1.0.0 # doc
SQLAlchemy==1.2.6
tilecloud==0.5.1 # Tile generation
tilecloud-chain==1.5.2 # Tile generation
tilecloud-chain==1.6.0.dev2 # Tile generation
transaction==2.2.1 # commons, geoportal
transifex-client==0.12.5 # Makefile, rq.filter: >=0.14
translationstring==1.3 # admin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
!mapserver/
!qgisserver/
!mapcache/
!tilegeneration/config.yaml
!tilegeneration/
!print/print-apps/
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ __pycache__/
/testdb/12-alembic.sql
/testdb/13-alembic-static.sql
/mapcache/
/tilegeneration/config.yaml
/tilegeneration/config.yaml.tmpl
/tilegeneration/config.yaml.mako
/print/print-apps/{{package}}/config.yaml.mako
/mapserver/mapserver.map.tmpl
/mapserver/*.map.tmpl
Expand Down
4 changes: 2 additions & 2 deletions geoportal/c2cgeoportal_geoportal/scaffolds/create/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ VOLUME /etc/mapserver
COPY mapcache /mapcache
VOLUME /mapcache

COPY tilegeneration /etc/tilecloudchain
VOLUME /etc/tilecloudchain
COPY tilegeneration /etc/tilegeneration
VOLUME /etc/tilegeneration

COPY print/print-apps /usr/local/tomcat/webapps/ROOT/print-apps
VOLUME /usr/local/tomcat/webapps/ROOT/print-apps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,20 @@ ${service_defaults('memcached', 11211)}\
${service_defaults('redis', 6379)}\

tilecloudchain:
image: camptocamp/tilecloud-chain:1.5.0
image: camptocamp/tilecloud-chain:1.6
volumes_from:
- config:ro
${service_defaults('mapserver', 80)}\
${service_defaults('tilecloudchain', 80)}\

tilegeneration:
image: camptocamp/tilecloud-chain:1.6
volumes_from:
- config:ro
${service_defaults('tilecloudchain')}\
entrypoint:
- bash
- -c
- sleep infinity

geoportal:
image: ${docker_base}-geoportal:${docker_tag}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ backend geoportal


backend tilecloudchain
option httpchk GET ${VISIBLE_ENTRY_POINT}tiles HTTP/1.0\r\nUser-Agent:\ healthcheck
option httpchk GET ${VISIBLE_ENTRY_POINT}c2c_tiles/health_check HTTP/1.0\r\nUser-Agent:\ healthcheck
http-check expect status 200
server linked tilecloudchain:80 resolvers dns #check

Expand All @@ -69,7 +69,7 @@ frontend plain
http-request set-var(req.path) path

# If the path starts with /tiles/, use the tilecloudchain backend
acl is_tiles var(req.path) -m beg ${VISIBLE_ENTRY_POINT}tiles/
acl is_tiles var(req.path) -m beg ${VISIBLE_ENTRY_POINT}tiles/ ${VISIBLE_ENTRY_POINT}static_tiles/ ${VISIBLE_ENTRY_POINT}c2c_tiles/
use_backend tilecloudchain if is_tiles

# Redirect all to geoportal by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ caches:
folder: /var/sig/tiles
wmtscapabilities_file: ${wmtscapabilities_path}
# for GetCapabilities
http_url: ${web_protocol}://${host}${entry_point}tiles/
http_url: ${web_protocol}://${host}${entry_point}
s3:
type: s3
bucket: tiles
Expand All @@ -33,7 +33,7 @@ defaults:
# The minimum resolution to seed, useful to use with mapcache, optional.
# min_resolution_seed: 1
# the URL of the WMS server to used
url: http://mapserver/
url: ${mapserver_url}
# Set the headers to get the right virtual host, and don't get any cached result
headers:
Host: '${host}'
Expand Down Expand Up @@ -101,8 +101,14 @@ generation:
# maximum allowed consecutive errors, after it exit [default to 10]
maxconsecutive_errors: 10

server:
mapcache_base: '${mapcache_url}'
wmts_path: tiles
static_path: static_tiles
expires: 8 # 8 hours

mapcache:
config_file: mapcache/mapcache.xml
config_file: mapcache/mapcache.xml.tmpl
memcache_host: localhost
memcache_port: 11211

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ __pycache__/
/mapserver/*.map.tmpl.mako
/mapserver/tinyows.xml
/tilegeneration/config.yaml
/tilegeneration/config.yaml.tmpl
/geoportal/jsbuild/app.cfg
/geoportal/Dockerfile
/geoportal/config.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export MAPSERVER_URL
PRINT_URL ?= http://print:8080/print/
export PRINT_URL
PRINT_CONFIG_FILE ?= print/print-apps/$(PACKAGE)/config.yaml
MAPCACHE_FILE ?= mapcache/mapcache.xml
TILEGENERATION_CONFIG_FILE = tilegeneration/config.yaml

VISIBLE_WEB_PROTOCOL ?= https
VISIBLE_WEB_PORT ?= 443
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,6 @@ files_to_move:
- from: print/print-apps/{{package}}/config.yaml.tmpl
to: print/print-apps/{{package}}/config.yaml.mako
version: 2.3
- from: tilegeneration/config.yaml.tmpl.mako
to: tilegeneration/config.yaml.mako
version: 2.3
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,6 @@ files_to_move:
- from: print/print-apps/{{package}}/config.yaml.mako
to: print/print-apps/{{package}}/config.yaml.tmpl
version: 2.3
- from: tilegeneration/config.yaml.mako
to: tilegeneration/config.yaml.tmpl.mako
version: 2.3
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ WMTSCAPABILITIES_PATH ?= 1.0.0/WMTSCapabilities-$(ENVIRONMENT).xml
export WMTSCAPABILITIES_PATH
ifeq ($(TILECLOUD_CHAIN), TRUE)
WMTSCAPABILITIES_FILE ?= /var/sig/tiles/$(WMTSCAPABILITIES_PATH)
MAPCACHE_FILE ?= mapcache/mapcache.xml
DEFAULT_BUILD_RULES += tilegeneration/config.yaml
MAPCACHE_FILE ?= mapcache/mapcache.xml.tmpl
TILEGENERATION_CONFIG_FILE = tilegeneration/config.yaml.tmpl
DEFAULT_BUILD_RULES += $(TILEGENERATION_CONFIG_FILE)
ifeq ($(TILECLOUD_CHAIN_LOCAL), TRUE)
DEFAULT_BUILD_RULES += $(WMTSCAPABILITIES_FILE)
endif
Expand Down Expand Up @@ -747,15 +748,15 @@ upgrade%:

# Tilecloud chain

$(MAPCACHE_FILE): tilegeneration/config.yaml
$(MAPCACHE_FILE): $(TILEGENERATION_CONFIG_FILE)
$(PRERULE_CMD)
mkdir --parent $(dir $@)
generate_controller --mapcache
generate_controller --config=$< --mapcache

$(WMTSCAPABILITIES_FILE): tilegeneration/config.yaml
$(WMTSCAPABILITIES_FILE): $(TILEGENERATION_CONFIG_FILE)
$(PRERULE_CMD)
mkdir --parent $(dir $@)
generate_controller --capabilities
generate_controller --config=$< --capabilities

# Secrets

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ vars:
PGPASSWORD: www-data
PGDATABASE: geomapfish
GEOPORTAL_INTERNAL_URL: 'http://geoportal/'
MAPCACHE_URL: http://mapcache/
MAPSERVER_URL: http://mapserver/
db:
environment:
POSTGRES_DB: geomapfish
Expand Down Expand Up @@ -63,6 +65,7 @@ vars:
environment:
VISIBLE_ENTRY_POINT: '{docker_entry_point}'
TILEGENERATION_CONFIGFILE: /etc/tilegeneration/config.yaml
C2C_BASE_PATH: /c2c_tiles
front:
port: 80

Expand Down Expand Up @@ -360,9 +363,11 @@ vars:

# For print proxy
print_url: '{PRINT_URL}'
mapserver_url: '{MAPSERVER_URL}'
mapcache_url: '{MAPCACHE_URL}'

pdfreport:
print_url: '{PRINT_URL}'
print_url: '{print_url}'

# For base layers
tiles_url:
Expand Down Expand Up @@ -550,6 +555,8 @@ runtime_environment:
default: http://mapserver/
- name: PRINT_URL
default: http://print:8080/print/
- name: MAPCACHE_URL
default: http://mapcache/
- name: REDIS_HOST
default: undefined # no error if absent
- name: REDIS_PORT
Expand Down

0 comments on commit d71d8f5

Please sign in to comment.