Skip to content

Commit

Permalink
add further files from gmf2.5.77 templates
Browse files Browse the repository at this point in the history
  • Loading branch information
mki-c2c committed Sep 22, 2020
1 parent cd85dfc commit 2e7fea1
Show file tree
Hide file tree
Showing 13 changed files with 735 additions and 148 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ trim_trailing_whitespace = true
[*.js]
indent_size = 2

[*.yaml]
indent_size = 2

[*.yml]
indent_size = 2

[Makefile]
indent_style = tab
59 changes: 59 additions & 0 deletions CONST_CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
This file includes migration steps for each release of c2cgeoportal.


Version 2.5.0
=============

Information
-----------

1. Basic authentication is disabled by default from this version onward.
To enable basic auth see:
https://camptocamp.github.io/c2cgeoportal/2.5/integrator/security.html#basic-auth

Changes to apply
----------------

1. Now we need to have PyYAML python package installed in the home,
see the documentation for more information:
https://camptocamp.github.io/c2cgeoportal/2.5/integrator/requirements.html

2. The configuration vars `vars/functionalities/anonymous` and `vars/functionalities/registered` should
be moved to the new roles `anonymous` and `registered` that will be created once the database has been upgraded.

3. The 'INSTANCE' configuration variable is removed, it should be in the '.env' files, and also the
environment makefiles, these contents should also be moved to the '.env' files. In a multi-organisation
project you can have a chain of multiple '.env' files see the build configuration documentation.

4. A new PostgreSQL extension is required, install it by running in psql:
`CREATE EXTENSION IF NOT EXISTS hstore;`

5. The static files will be moved, therefore you should replace:
`request.static_url('geoportailv3_geoportal:static/` by:
`request.static_url('/etc/geomapfish/static/`.

6. Optional, change your mapfiles according the documentation:
https://camptocamp.github.io/c2cgeoportal/2.5/administrator/mapfile.html


Version 2.4.2
=============

Information
-----------

1. The SVG inclusion through Webpack has changed, See ngeo SVG example for more information:
https://camptocamp.github.io/ngeo/master/examples/svg.html

2. The WMTS capabilities is now generated on runtime.

3. If not already done the 'edit' and 'routing' interfaces and their relations will be removed from the
database, If you don't want that, you should rename the interfaces before applying the alembic scripts.

4. If not already done the 'api' and 'iframe_api' will be created. After the database upgrade you can run
the following request to fill e.-g. the api's interfaces with the desktop interface:

INSERT INTO main.interface_layer (interface_id, layer_id)
SELECT <api_interface_id>, layer_id FROM main.interface_layer WHERE interface_id = <other_interface_id>;
INSERT INTO main.interface_theme (interface_id, theme_id)
SELECT <api_interface_id>, theme_id FROM main.interface_theme WHERE interface_id = <other_interface_id>;
66 changes: 66 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
FROM camptocamp/geomapfish-tools:2.5.0.77 as builder

ENV LANGUAGES="en fr de"
ENV VARS_FILE=vars.yaml
ENV CONFIG_VARS sqlalchemy.url sqlalchemy.pool_recycle sqlalchemy.pool_size sqlalchemy.max_overflow \
sqlalchemy.use_batch_mode sqlalchemy_slave.url sqlalchemy_slave.pool_recycle sqlalchemy_slave.pool_size \
sqlalchemy_slave.max_overflow sqlalchemy_slave.use_batch_mode schema schema_static enable_admin_interface \
default_locale_name servers layers available_locale_names cache admin_interface getitfixed functionalities \
raster shortener hide_capabilities tinyowsproxy resourceproxy print_url print_get_redirect \
checker check_collector default_max_age package srid \
reset_password fulltextsearch global_headers headers authorized_referers hooks stats db_chooser \
dbsessions urllogin host_forward_host smtp c2c.base_path welcome_email \
lingua_extractor interfaces_config interfaces devserver_url api authentication intranet metrics pdfreport

COPY . /tmp/config/

RUN \
for lang in ${LANGUAGES}; \
do \
node /usr/bin/compile-catalog \
/opt/c2cgeoportal/geoportal/c2cgeoportal_geoportal/locale/${lang}/LC_MESSAGES/ngeo.po \
/opt/c2cgeoportal/geoportal/c2cgeoportal_geoportal/locale/${lang}/LC_MESSAGES/gmf.po \
/tmp/config/geoportal/geoportailv3_geoportal/locale/${lang}/LC_MESSAGES/geoportailv3_geoportal-client.po \
> /tmp/config/geoportal/geoportailv3_geoportal/static/${lang}.json; \
done && \
rm -rf /tmp/config/geoportal/geoportailv3_geoportal/locale

RUN \
cd /tmp/config/geoportal/ && \
c2c-template --vars ${VARS_FILE} \
--get-config geoportailv3_geoportal/config.yaml \
${CONFIG_VARS} && \
pykwalify --data-file geoportailv3_geoportal/config.yaml \
--schema-file CONST_config-schema.yaml && \
rm CONST_* vars.yaml

###############################################################################

FROM camptocamp/geomapfish-config:2.5.0.77

ARG PGSCHEMA
ENV PGSCHEMA=$PGSCHEMA

COPY --from=builder /tmp/config/ /tmp/config/

RUN \
if [ -e /tmp/config/mapserver ]; then mv /tmp/config/mapserver /etc/; fi && \
if [ -e /tmp/config/tilegeneration ]; then mv /tmp/config/tilegeneration /etc/; fi && \
if [ -e /tmp/config/qgisserver ]; then mv /tmp/config/qgisserver /etc/qgisserver; fi && \
mkdir --parent /usr/local/tomcat/webapps/ROOT/ && \
if [ -e /tmp/config/print ]; then mv /tmp/config/print/print-apps /usr/local/tomcat/webapps/ROOT/; fi && \
mv /tmp/config/geoportal/geoportailv3_geoportal/ /etc/geomapfish/ && \
chmod g+w -R /etc /usr/local/tomcat/webapps && \
adduser www-data root && \
sed 's#bind :80#bind *:443 ssl crt /etc/haproxy_dev/localhost.pem#g' /etc/haproxy/haproxy.cfg.tmpl \
> /etc/haproxy_dev/haproxy.cfg.tmpl && \
echo ' http-request set-header X-Forwarded-Proto https' >> /etc/haproxy_dev/haproxy.cfg.tmpl

VOLUME /etc/geomapfish \
/etc/mapserver \
/etc/qgisserver \
/etc/tilegeneration \
/usr/local/tomcat/webapps/ROOT/print-apps \
/etc/gunicorn \
/etc/haproxy_dev \
/etc/haproxy
144 changes: 144 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/usr/bin/env python3

import argparse
import os
import os.path
import platform
import re
import stat
import subprocess
import sys
import urllib.request

import yaml


def call(verbose, arguments, **kwargs):
if verbose:
print_args = [a.replace(" ", "\\ ") for a in arguments]
print_args = [a.replace('"', '\\"') for a in print_args]
print_args = [a.replace("'", "\\'") for a in print_args]
print(" ".join(print_args))
subprocess.check_call(arguments, **kwargs)


def load_env(env_files):
"""
Parse env files and return environment as dict
"""
env = {}
for env_file in env_files:
with open(env_file) as f:
for line in f:
if line and line[0] != "#":
try:
index = line.index("=")
env[line[:index].strip()] = line[index + 1 :].strip()
except ValueError:
# Ignore lines that don't have a '='
pass
return env


def main():
parser = argparse.ArgumentParser(description="Build the project")
parser.add_argument("--verbose", help="Display the docker build commands")
parser.add_argument("--config", action="store_true", help="Build only the configuration image")
parser.add_argument("--geoportal", action="store_true", help="Build only the geoportal image")
parser.add_argument("--upgrade", help="Start upgrading the project to version")
parser.add_argument("env", nargs="*", help="The environment config")
args = parser.parse_args()

if args.upgrade:
major_version = args.upgrade
match = re.match(r"^([0-9]+\.[0-9]+)\.[0-9]+$", args.upgrade)
if match is not None:
major_version = match.group(1)
match = re.match(r"^([0-9]+\.[0-9]+)\.[0-9]+\.[0-9]+$", args.upgrade)
if match is not None:
major_version = match.group(1)
full_version = args.upgrade if args.upgrade != "master" else "latest"
with open("upgrade", "w") as f:
result = urllib.request.urlopen(
"https://raw.githubusercontent.com/camptocamp/c2cgeoportal/{}/scripts/upgrade".format(
major_version
)
)
if result.code != 200:
print("ERROR:")
print(result.read())
sys.exit(1)
f.write(result.read().decode())
os.chmod("upgrade", os.stat("upgrade").st_mode | stat.S_IXUSR)
try:
if platform.system() == "Windows":
subprocess.check_call(["python", "upgrade", full_version])
else:
subprocess.check_call(["./upgrade", full_version])
except subprocess.CalledProcessError:
sys.exit(1)
sys.exit(0)

with open("project.yaml") as project_file:
project_env = yaml.load(project_file, Loader=yaml.SafeLoader)["env"]
if len(args.env) != project_env["required_args"]:
print(project_env["help"])
sys.exit(1)
env_files = [e.format(*args.env) for e in project_env["files"]]
print("Use env files: {}".format(", ".join(env_files)))
for env_file in env_files:
if not os.path.exists(env_file):
print("Error: the env file '{}' does not exist.".format(env_file))
sys.exit(1)
env = load_env(env_files)

base = env["DOCKER_BASE"] if "DOCKER_BASE" in env else "camptocamp/geoportailv3"
tag = ":" + env["DOCKER_TAG"] if "DOCKER_TAG" in env else ""
schema = env["PGSCHEMA"]

default = not (args.config or args.geoportal)

if default or args.config:
call(
args.verbose,
[
"docker",
"build",
"--tag={}-config{}".format(base, tag),
"--build-arg=PGSCHEMA=" + schema,
".",
],
)
if default or args.geoportal:
git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode()
call(
args.verbose,
[
"docker",
"build",
"--tag={}-geoportal{}".format(base, tag),
"--build-arg=PGSCHEMA=" + schema,
"--build-arg=GIT_HASH=" + git_hash,
"geoportal",
],
)
call(
args.verbose,
[
"docker",
"build",
"--target=builder",
"--tag={}-geoportal-dev{}".format(base, tag),
"geoportal",
],
)

with open(".env", "w") as dest:
for file_ in env_files:
with open(file_) as src:
dest.write(src.read() + "\n")
dest.write("# Used env files: {}\n".format(" ".join(env_files)))


if __name__ == "__main__":
main()
Loading

0 comments on commit 2e7fea1

Please sign in to comment.