Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able to configure the PGSCHEMA in mapserver #4986

Merged
merged 1 commit into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions doc/integrator/database.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@ integration and production => ``main_2018``

The schema ``main_2017`` still exists to be able to rollback the production.

To do that we should manage the ``PGSCHEMA`` and the ``PGSCHEMA_STATIC`` variable in your makefiles.
To do that we should manage the ``PGSCHEMA`` and the ``DOCKER_PGSCHEMA_STATIC`` variable in your
makefiles.

The ``PGSCHEMA`` should be set in the ``Makefile`` and the ``PGSCHEMA_STATIC`` for the production should be
set in a specific makefile for the production e.-g. ``production.mk``.
The ``PGSCHEMA`` should be set in the ``Makefile`` and the ``DOCKER_PGSCHEMA_STATIC`` for the
production should be set in a specific makefile for the production e.-g. ``production.mk``.

To to the schema we provide a Postgres function, to create it:
And the line `PGSCHEMA=${docker_schema}` should be removed from your `.env.mako` file.

To copy the schema, we provide a Postgres function, to create it use:

.. prompt:: bash

sudo -u postgres psql <database> --file=scripts/CONST_clone_schema.sql
docker-compose exec geoporal psql <database> --file=scripts/CONST_clone_schema.sql

To use it:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM camptocamp/geomapfish-config-build:${geomapfish_version}

ARG PGSCHEMA
ENV PGSCHEMA=$PGSCHEMA

COPY . /tmp/config/

RUN mv /tmp/config/bin/* /usr/bin/ && \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,31 @@ import re
import urllib.parse
import subprocess

os.environ["DOLLAR"] = '$'
os.environ["VISIBLE_WEB_HOST_RE_ESCAPED"] = re.escape(os.environ.get('VISIBLE_WEB_HOST'))
os.environ["VISIBLE_ENTRY_POINT_RE_ESCAPED"] = re.escape(os.environ.get('VISIBLE_ENTRY_POINT'))
os.environ["DOLLAR"] = '$'
os.environ["MAPSERVER_DATA_SUBSELECT"] = (
"SELECT ST_Collect(ra.area) "
"FROM {PGSCHEMA}.restrictionarea AS ra, {PGSCHEMA}.role_restrictionarea AS rra, "
"{PGSCHEMA}.layer_restrictionarea AS lra, {PGSCHEMA}.treeitem AS la "
"WHERE rra.role_id in (%role_ids%) AND rra.restrictionarea_id = ra.id "
"AND lra.restrictionarea_id = ra.id AND lra.layer_id = la.id AND la.name = "
).format(PGSCHEMA=os.environ["PGSCHEMA"])
os.environ["MAPSERVER_DATA_NOAREA_SUBSELECT"] = (
"SELECT rra.role_id "
"FROM {PGSCHEMA}.restrictionarea AS ra, {PGSCHEMA}.role_restrictionarea AS rra, "
"{PGSCHEMA}.layer_restrictionarea AS lra, {PGSCHEMA}.treeitem AS la "
"WHERE rra.restrictionarea_id = ra.id AND lra.restrictionarea_id = ra.id "
"AND lra.layer_id = la.id AND la.name = "
).format(PGSCHEMA=os.environ["PGSCHEMA"])
os.environ["MAPSERVER_JOIN_TABLES"] = (
"{PGSCHEMA}.restrictionarea AS ra, {PGSCHEMA}.role_restrictionarea AS rra, "
"{PGSCHEMA}.layer_restrictionarea AS lra, {PGSCHEMA}.treeitem AS la"
).format(PGSCHEMA=os.environ["PGSCHEMA"])
os.environ["MAPSERVER_JOIN_WHERE"] = (
"rra.role_id in (%role_ids%) AND rra.restrictionarea_id = ra.id AND "
"lra.restrictionarea_id = ra.id AND lra.layer_id = la.id AND la.name = "
)

SCHEME_PORT = {
"http": 80,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ services:
- PGUSER
- PGPASSWORD
- PGDATABASE
- PGSCHEMA
- PGSCHEMA_STATIC
- GEOPORTAL_INTERNAL_URL
- TILECLOUDCHAIN_INTERNAL_URL
Expand All @@ -31,20 +30,6 @@ services:
- AWS_SECRET_ACCESS_KEY
- AWS_DEFAULT_REGION
- AWS_S3_ENDPOINT
- "MAPSERVER_DATA_SUBSELECT=SELECT ST_Collect(ra.area)
FROM ${PGSCHEMA}.restrictionarea AS ra, ${PGSCHEMA}.role_restrictionarea AS rra,
${PGSCHEMA}.layer_restrictionarea AS lra, ${PGSCHEMA}.treeitem AS la
WHERE rra.role_id in (%role_ids%) AND rra.restrictionarea_id = ra.id
AND lra.restrictionarea_id = ra.id AND lra.layer_id = la.id AND la.name = "
- "MAPSERVER_DATA_NOAREA_SUBSELECT=SELECT rra.role_id
FROM ${PGSCHEMA}.restrictionarea AS ra, ${PGSCHEMA}.role_restrictionarea AS rra,
${PGSCHEMA}.layer_restrictionarea AS lra, ${PGSCHEMA}.treeitem AS la
WHERE rra.restrictionarea_id = ra.id AND lra.restrictionarea_id = ra.id
AND lra.layer_id = la.id AND la.name = "
- "MAPSERVER_JOIN_TABLES=${PGSCHEMA}.restrictionarea AS ra, ${PGSCHEMA}.role_restrictionarea AS rra,
${PGSCHEMA}.layer_restrictionarea AS lra, ${PGSCHEMA}.treeitem AS la"
- "MAPSERVER_JOIN_WHERE=rra.role_id in (%role_ids%) AND rra.restrictionarea_id = ra.id AND
lra.restrictionarea_id = ra.id AND lra.layer_id = la.id AND la.name = "

print:
image: camptocamp/mapfish_print:3.16
Expand Down Expand Up @@ -73,7 +58,6 @@ services:
- PGUSER
- PGPASSWORD
- PGDATABASE
- PGSCHEMA
- PGSCHEMA_STATIC
- C2C_REDIS_URL
- C2C_BROADCAST_PREFIX
Expand Down Expand Up @@ -166,7 +150,6 @@ services:
- PGUSER
- PGPASSWORD
- PGDATABASE
- PGSCHEMA
- PGSCHEMA_STATIC
- GUNICORN_PARAMS
- VISIBLE_WEB_HOST
Expand Down Expand Up @@ -201,7 +184,6 @@ services:
- PGUSER
- PGPASSWORD
- PGDATABASE
- PGSCHEMA
- PGSCHEMA_STATIC

front:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ services:
extends:
file: docker-compose-lib.yaml
service: config
environment:
- PGSCHEMA

## print:
## extends:
Expand All @@ -33,12 +35,13 @@ services:
## volumes_from:
## - config:ro
## environment:
## - PGSCHEMA
## # Single QGIS project files
## QGIS_PROJECT_FILE: /etc/qgisserver/project.qgz
## GEOMAPFISH_OGCSERVER: <OGC server name>
## - QGIS_PROJECT_FILE=/etc/qgisserver/project.qgz
## - GEOMAPFISH_OGCSERVER=<OGC server name>
## # Multiple QGIS project files
## # QGIS_PROJECT_FILE:
## # GEOMAPFISH_ACCESSCONTROL_CONFIG: /etc/qgisserver/accesscontrol_config.yaml
## - QGIS_PROJECT_FILE=
## - GEOMAPFISH_ACCESSCONTROL_CONFIG=/etc/qgisserver/accesscontrol_config.yaml

tinyows:
extends:
Expand Down Expand Up @@ -84,11 +87,15 @@ services:
service: geoportal
volumes:
- /var/sig:/var/sig:ro
environment:
- PGSCHEMA

alembic:
extends:
file: docker-compose-lib.yaml
service: alembic
environment:
- PGSCHEMA

front:
extends:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ DOCKER_PGHOST_SLAVE ?= 172.17.0.1
DOCKER_PGPORT ?= 5432
DOCKER_PGDATABASE ?= geomapfish
DOCKER_PGSCHEMA ?= main
PGSCHEMA ?= main
DOCKER_PGSCHEMA_STATIC ?= main_static
export DOCKER_PORT
export DOCKER_BASE
Expand Down Expand Up @@ -696,7 +697,8 @@ docker-build-config: $(shell docker-required --path .) \
$(PRINT_CONFIG_FILE) \
$(MAPCACHE_FILE) \
qgisserver/geomapfish.yaml
docker build --tag=$(DOCKER_BASE)-config:$(DOCKER_TAG) .
docker build --tag=$(DOCKER_BASE)-config:$(DOCKER_TAG) \
--build-arg=PGSCHEMA=$(PGSCHEMA) .

.PHONY: docker-build-geoportal
docker-build-geoportal: $(shell docker-required --path geoportal) \
Expand All @@ -705,7 +707,8 @@ docker-build-geoportal: $(shell docker-required --path geoportal) \
geoportal/config.yaml \
geoportal/alembic.ini \
geoportal/alembic.yaml
docker build --tag=$(DOCKER_BASE)-geoportal:$(DOCKER_TAG) --build-arg=GIT_HASH=$(GIT_HASH) geoportal
docker build --tag=$(DOCKER_BASE)-geoportal:$(DOCKER_TAG) \
--build-arg=GIT_HASH=$(GIT_HASH) geoportal

.PHONY: push-docker
push-docker:
Expand Down