diff --git a/.editorconfig b/.editorconfig index 5b1d828a0..6da856443 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,5 +11,11 @@ trim_trailing_whitespace = true [*.js] indent_size = 2 +[*.yaml] +indent_size = 2 + +[*.yml] +indent_size = 2 + [Makefile] indent_style = tab diff --git a/CONST_CHANGELOG.txt b/CONST_CHANGELOG.txt new file mode 100644 index 000000000..eeeda5125 --- /dev/null +++ b/CONST_CHANGELOG.txt @@ -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 , layer_id FROM main.interface_layer WHERE interface_id = ; + INSERT INTO main.interface_theme (interface_id, theme_id) + SELECT , theme_id FROM main.interface_theme WHERE interface_id = ; diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..679dfea53 --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/build b/build new file mode 100755 index 000000000..8fd910c5e --- /dev/null +++ b/build @@ -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() diff --git a/docker-compose-lib.yaml b/docker-compose-lib.yaml new file mode 100644 index 000000000..7f60e321c --- /dev/null +++ b/docker-compose-lib.yaml @@ -0,0 +1,251 @@ +--- + +version: '2.0' + +services: + config: + image: ${DOCKER_BASE}-config:${DOCKER_TAG} + user: www-data + environment: + - VISIBLE_WEB_HOST + - VISIBLE_WEB_PROTOCOL + - VISIBLE_ENTRY_POINT + - PGHOST + - PGHOST_SLAVE + - PGPORT + - PGPORT_SLAVE + - PGUSER + - PGPASSWORD + - PGDATABASE + - PGSSLMODE + - PGSCHEMA_STATIC + - GEOPORTAL_INTERNAL_URL + - GEOPORTAL_INTERNAL_HOST + - GEOPORTAL_INTERNAL_PORT + - TILECLOUDCHAIN_INTERNAL_URL + - TILECLOUDCHAIN_INTERNAL_HOST + - TILECLOUDCHAIN_INTERNAL_PORT + - MAPSERVER_URL + - REDIS_HOST + - REDIS_PORT + - REDIS_DB + - TILEGENERATION_SQS_QUEUE + - TILEGENERATION_S3_BUCKET + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_DEFAULT_REGION + - AWS_S3_ENDPOINT + + print: + image: camptocamp/mapfish_print:3.22 + user: www-data + restart: unless-stopped + environment: + - CATALINA_OPTS + - PGOPTIONS + + mapserver: + image: camptocamp/mapserver:7.4 + user: www-data + restart: unless-stopped + entrypoint: [] + environment: + - PGOPTIONS + + qgisserver: + image: camptocamp/geomapfish-qgisserver:gmf2.5-qgis${QGIS_VERSION} + user: www-data + restart: unless-stopped + environment: + - PGHOST + - PGHOST_SLAVE + - PGPORT + - PGPORT_SLAVE + - PGUSER + - PGPASSWORD + - PGDATABASE + - PGSSLMODE + - PGSCHEMA_STATIC + - C2C_REDIS_URL + - C2C_BROADCAST_PREFIX + - PGOPTIONS + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_DEFAULT_REGION + - AWS_S3_ENDPOINT + - CPL_VSIL_CURL_USE_CACHE + - CPL_VSIL_CURL_CACHE_SIZE + - CPL_VSIL_CURL_USE_HEAD + - GDAL_DISABLE_READDIR_ON_OPEN + - QGIS_SERVER_LOG_LEVEL=2 + - LOG_LEVEL=INFO + - C2CGEOPORTAL_LOG_LEVEL + - SQL_LOG_LEVEL + - OTHER_LOG_LEVEL + + tinyows: + image: camptocamp/tinyows + user: www-data + restart: unless-stopped + + redis: + image: redis:5 + user: www-data + restart: unless-stopped + command: + - redis-server + - --save + - '' + - --appendonly + - 'no' + - --maxmemory + - 512mb + - --maxmemory-policy + - volatile-lru + - --tcp-keepalive + - '30' + + tilecloudchain: + image: camptocamp/tilecloud-chain:1.13 + user: www-data + restart: unless-stopped + environment: + - GUNICORN_PARAMS + - VISIBLE_ENTRY_POINT + - C2C_REDIS_URL + - TILEGENERATION_CONFIGFILE=/etc/tilegeneration/config.yaml + - C2C_BASE_PATH=/tiles/c2c + - C2C_BROADCAST_PREFIX=broadcast_tilecloudchain_ + - C2C_LOG_VIEW_ENABLED=TRUE + - C2C_DEBUG_VIEW_ENABLED=TRUE + - C2C_SQL_PROFILER_ENABLED=TRUE + - C2C_SECRET + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + + tilegeneration_slave: + image: camptocamp/tilecloud-chain:1.13 + user: www-data + restart: unless-stopped + entrypoint: + - generate_tiles + - --role=slave + - --daemon + environment: + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + + geoportal: + image: ${DOCKER_BASE}-geoportal:${DOCKER_TAG} + user: www-data + restart: unless-stopped + environment: &env + - VISIBLE_ENTRY_POINT + - PACKAGE=geoportailv3 + - PGHOST + - PGHOST_SLAVE + - PGPORT + - PGPORT_SLAVE + - PGUSER + - PGPASSWORD + - PGDATABASE + - PGSSLMODE + - PGSCHEMA_STATIC + - PGOPTIONS + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_DEFAULT_REGION + - AWS_S3_ENDPOINT + - GUNICORN_PARAMS + - VISIBLE_WEB_HOST + - VISIBLE_WEB_PROTOCOL + - AUTHTKT_TIMEOUT + - AUTHTKT_REISSUE_TIME + - AUTHTKT_MAXAGE + - AUTHTKT_SECRET + - AUTHTKT_COOKIENAME + - AUTHTKT_HTTP_ONLY + - AUTHTKT_SECURE + - AUTHTKT_SAMESITE + - BASICAUTH + - TINYOWS_URL + - MAPSERVER_URL + - QGISSERVER_URL + - PRINT_URL + - DEVSERVER_HOST + - REDIS_HOST + - REDIS_PORT + - REDIS_DB + - C2C_REDIS_URL + - C2C_BROADCAST_PREFIX + - C2C_LOG_VIEW_ENABLED=TRUE + - C2C_SQL_PROFILER_ENABLED=TRUE + - C2C_DEBUG_VIEW_ENABLED=TRUE + - C2C_SECRET + - LOG_LEVEL + - C2CGEOPORTAL_LOG_LEVEL + - SQL_LOG_LEVEL + - GUNICORN_LOG_LEVEL + - OTHER_LOG_LEVEL + - DOGPILECACHE_LOG_LEVEL + - LOG_TYPE + + tools: + image: camptocamp/geomapfish-tools:2.5.0.77 + restart: unless-stopped + environment: *env + + alembic: + image: ${DOCKER_BASE}-geoportal:${DOCKER_TAG} + user: www-data + entrypoint: [] + command: + - alembic + - --name=static + - upgrade + - head + environment: + - PGHOST + - PGHOST_SLAVE + - PGPORT + - PGPORT_SLAVE + - PGUSER + - PGPASSWORD + - PGDATABASE + - PGSSLMODE + - PGSCHEMA_STATIC + - LOG_TYPE + + front: + image: haproxy:1.9 + restart: unless-stopped + volumes: + - /dev/log:/dev/log:rw + command: + - haproxy + - -f + - /etc/${FRONT_CONFIG} + ports: + - ${DOCKER_PORT}:${FRONT_INNER_PORT} + + webpack_dev_server: + image: ${DOCKER_BASE}-geoportal-dev:${DOCKER_TAG} + volumes: + - ./geoportal/geoportailv3_geoportal/static-ngeo:/app/geoportailv3_geoportal/static-ngeo + environment: + - VISIBLE_ENTRY_POINT + - VISIBLE_WEB_HOST + - VISIBLE_WEB_PROTOCOL + - PGHOST + - PGHOST_SLAVE + - PGPORT + - PGPORT_SLAVE + - PGUSER + - PGPASSWORD + - PGDATABASE + - PGSSLMODE + - PGSCHEMA_STATIC + - AWS_ACCESS_KEY_ID + - AWS_SECRET_ACCESS_KEY + - AWS_DEFAULT_REGION + - AWS_S3_ENDPOINT diff --git a/docker-compose.override.sample.yaml b/docker-compose.override.sample.yaml new file mode 100644 index 000000000..17045bb85 --- /dev/null +++ b/docker-compose.override.sample.yaml @@ -0,0 +1,54 @@ +--- +# This file can be renamed as `docker-compose.override.yaml` and uncomment the desired lines for +# development. The file `docker-compose.override.yaml` is ignored by Git by default. + +# yamllint disable rule:line-length + +version: '2.0' + +services: + geoportal: + user: root + volumes: + # For Python project development. + - ./geoportal/geoportailv3_geoportal:/app/geoportailv3_geoportal + # For Python c2cgeportal development. + # - ./../c2cgeoportal/commons/c2cgeoportal_commons:/opt/c2cgeoportal/commons/c2cgeoportal_commons + # - ./../c2cgeoportal/geoportal/c2cgeoportal_geoportal:/opt/c2cgeoportal/geoportal/c2cgeoportal_geoportal + # - ./../c2cgeoportal/admin/c2cgeoportal_admin:/opt/c2cgeoportal/admin/c2cgeoportal_admin + environment: + - GUNICORN_CMD_ARGS=--reload + - C2CWSGIUTILS_CONFIG=/app/development.ini + # - PRINT_URL=http://print:8080/print/ + ports: + - 5678:5678 # For remote debugging using Visual Studio Code + + # Also uncomment the PRINT_URL in geoportal + # print: + # extends: + # file: docker-compose-lib.yaml + # service: print + # volumes_from: + # - config:ro + + qgisserver: + # volumes: + # - './../c2cgeoportal/docker/qgisserver/geomapfish_qgisserver/:/var/www/plugins/geomapfish_qgisserver/' + # - './../c2cgeoportal/commons/c2cgeoportal_commons:/opt/c2cgeoportal/commons/c2cgeoportal_commons/' + environment: + - QGIS_SERVER_LOG_LEVEL=0 + + # For Javascript project development. + # The debug application will be availavble at ``https:////dev/.html``. + webpack_dev_server: + # Uncomment these lines when you want to debug respectively the project js, ngeo js and/or the gmf contrib js. + # Adapt the path for ngeo / gmf contrib to point where you have checkouted the code. + # volumes: + # - ./geoportal/geoportailv3_geoportal/static-ngeo:/app/geoportailv3_geoportal/static-ngeo + # - ./../ngeo/src:/usr/lib/node_modules/ngeo/src + # - ./../ngeo/contribs:/usr/lib/node_modules/ngeo/contribs + volumes_from: + - config:rw + extends: + file: docker-compose-lib.yaml + service: webpack_dev_server diff --git a/docker-compose.yaml b/docker-compose.yaml index 0d78bc72a..20e91cd13 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,21 +2,18 @@ # The project Docker compose file for development. -version: '2' +version: '2.0' services: config: - image: camptocamp/geoportailv3-config:${DOCKER_TAG} -# user: www-data - environment: - - VISIBLE_WEB_HOST - - VISIBLE_WEB_PROTOCOL - - VISIBLE_ENTRY_POINT - - GEOPORTAL_INTERNAL_URL + extends: + file: docker-compose-lib.yaml + service: config print: - image: camptocamp/mapfish_print:3.18.4 - user: www-data + extends: + file: docker-compose-lib.yaml + service: print volumes_from: - config:ro ports: @@ -24,137 +21,44 @@ services: environment: - CATALINA_OPTS=-Xmx1024m - PGOPTIONS=-c statement_timeout=30000 -# - DEFAULT_LOG_LEVEL=DEBUG -# - TOMCAT_LOG_LEVEL=DEBUG -# - LOG_LEVEL=DEBUG -# - SPRING_LOG_LEVEL=DEBUG -# - JASPER_LOG_LEVEL=DEBUG -# - APACHE_LOG_LEVEL=DEBUG -# - SQL_LOG_LEVEL=DEBUG + + redis: + extends: + file: docker-compose-lib.yaml + service: redis geoportal: - image: camptocamp/geoportailv3-geoportal:${DOCKER_TAG} -# user: www-data + extends: + file: docker-compose-lib.yaml + service: geoportal + volumes_from: + - config:ro volumes: - /var/sig:/var/sig:ro - - ./data:/var/luxdata:ro - - ./geoportal/geoportailv3_geoportal/views:/app/geoportailv3_geoportal/views:ro - - ./geoportal/geoportailv3_geoportal/routing:/app/geoportailv3_geoportal/routing:ro - - ./geoportal/c2cgeoportal/geoportal/c2cgeoportal_geoportal/routing:/app/c2cgeoportal/geoportal/c2cgeoportal_geoportal/routing:ro - - ./geoportal/c2cgeoportal/geoportal/c2cgeoportal_geoportal/templates:/app/c2cgeoportal/geoportal/c2cgeoportal_geoportal/templates:ro - - ./geoportal/geoportailv3_geoportal/templates:/app/geoportailv3_geoportal/templates:ro - - ./geoportal/geoportailv3_geoportal/scripts:/app/geoportailv3_geoportal/scripts:ro - - ./geoportal/geoportailv3_geoportal/lib:/app/geoportailv3_geoportal/lib:ro - - ./geoportal/geoportailv3_geoportal/static-ngeo/js:/app/geoportailv3_geoportal/static-ngeo/js:ro - - ./geoportal/geoportailv3_geoportal/static-ngeo/less:/app/geoportailv3_geoportal/static-ngeo/less:ro - - ./geoportal/jsapi:/app/apiv3/jsapi:ro -# entrypoint: ['/usr/local/bin/alembic', '--config', '/app/alembic.ini', '--name', 'main', 'heads'] - environment: - - AUTHTKT_TIMEOUT - - AGE_CRUES_EMAIL - - AGE_CRUES_MAP_ID - - AGE_CRUES_SHOW_LINK - - AGE_CRUES_LAYERS - - AGE_CRUES_ROLES - - PAG_STAGING_URL - - PAG_PROD_URL - - PAG_FME_TOKEN - - PAG_OWNCLOUD_INTERNAL_URL - - PAG_OWNCLOUD_EXTERNAL_URL - - PAG_OWNCLOUD_USER - - PAG_OWNCLOUD_PASSWORD - - PAG_SMTP_SERVER - - PAG_BCC_ADDRESS - - PAG_FILE_SERVER - - PDS_STAGING_URL - - PDS_PROD_URL - - PDS_SMTP_SERVER - - PDS_BCC_ADDRESS - - CASIPO_STAGING_URL - - CASIPO_PROD_URL - - CASIPO_FME_TOKEN - - CASIPO_OWNCLOUD_INTERNAL_URL - - CASIPO_OWNCLOUD_EXTERNAL_URL - - CASIPO_OWNCLOUD_USER - - CASIPO_OWNCLOUD_PASSWORD - - CASIPO_SMTP_SERVER - - CASIPO_BCC_ADDRESS - - ANF_EMAIL - - ANF_MAP_ID - - DEBUG_TOOLBAR=1 - - DB_MYMAPS - - DB_PGROUTE - - DB_ECADASTRE - - DB_POI - - VISIBLE_ENTRY_POINT - - VISIBLE_WEB_HOST - - VISIBLE_WEB_PROTOCOL - - PGHOST - - PGHOST_SLAVE - - PGPORT - - PGUSER - - PGPASSWORD - - PGDATABASE - - PGSCHEMA - - PGSCHEMA_STATIC - - PGOPTIONS - - PRINT_URL - - GUNICORN_PARAMS=--bind=:8080 --threads=10 --timeout=60 --reload --forwarded-allow-ips=* - - LOG_LEVEL=INFO - - C2CGEOPORTAL_LOG_LEVEL=INFO - - C2CWSGIUTILS_CONFIG=/app/development.ini - - SQL_LOG_LEVEL=INFO - - GUNICORN_LOG_LEVEL=INFO - - GUNICORN_ACCESS_LOG_LEVEL=INFO - - IGNORE_I18N_ERRORS=TRUE - - OTHER_LOG_LEVEL=WARN - - DEVSERVER_HOST - - REDIS_HOST - - REDIS_PORT - - C2C_REDIS_URL - - LDAP_BASE_DN - - LDAP_BIND - - LDAP_PASSWD - - LDAP_URL - - LDAP_FILTER_TMPL - - MAILER_DIRECTORY - - DEFAULT_MYMAPS_ROLE - - DHM_DEM_FILE=/var/luxdata/dem500.tif - - DHM_DEM_TYPE=gdal - - FAKE_REVERSE_GEOCODING=1 - - FAKE_FULLTEXT_SEARCH=1 - - FAKE_LAYERSEARCH=0 - - FAKE_CMSSEARCH=1 - - FAKE_PRINT_URLS=http://print:8080/print/geoportailv3,http://print:8080/print/geoportailv3 - - SHORTENER_BASE_URL - - SHORTENER_ALLOWED_HOST - - ELASTIC_SERVERS - - ELASTIC_INDEX - - ROUTING_GRAPHHOPPER_API_KEY - - ROUTING_MAPQUEST_API_KEY - - AUTHTKT_SECURE=false - - AUTHTKT_SECRET=a_super_secret_for_auth_at_least_64_characters_long_for_sha512_algo_otherwise_not_good - ports: - - 8080:8080 - redis: - image: redis:3.2 - user: www-data - restart: unless-stopped - command: - - redis-server - - --save - - '' - - --appendonly - - 'no' - - --maxmemory - - 512mb - - --maxmemory-policy - - allkeys-lru + alembic: + extends: + file: docker-compose-lib.yaml + service: alembic - ldap: - image: lux-dev-ldap + front: + extends: + file: docker-compose-lib.yaml + service: front + volumes_from: + - config:ro + + # Rich image for project development with e.-g. vim, tree, awscli, psql, ... + tools: + volumes_from: + - config:rw + volumes: + - .:/src + extends: + file: docker-compose-lib.yaml + service: tools + # lux specific additions elasticsearch: image: elasticsearch:5.0 environment: @@ -164,17 +68,6 @@ services: ports: - 9200:9200 - alembic: - image: camptocamp/geoportailv3-geoportal:${DOCKER_TAG} -# user: www-data - command: ./bin/alembic_upgrade_all.sh - environment: - - PGHOST - - PGHOST_SLAVE - - PGPORT - - PGUSER - - PGPASSWORD - - PGDATABASE - - PGSCHEMA - - PGSCHEMA_STATIC - - PGOPTIONS + ldap: + image: lux-dev-ldap + diff --git a/env.default b/env.default new file mode 100644 index 000000000..155270e3f --- /dev/null +++ b/env.default @@ -0,0 +1,49 @@ +# Default values for c2cgeoportal +COMPOSE_PROJECT_NAME=geoportailv3 +DOCKER_PORT=8484 +DOCKER_BASE=camptocamp/geoportailv3 +DOCKER_TAG=latest +VISIBLE_WEB_HOST=localhost:8484 +VISIBLE_WEB_PROTOCOL=https +VISIBLE_ENTRY_POINT=/ +AUTHTKT_TIMEOUT=86400 +AUTHTKT_REISSUE_TIME=9000 +AUTHTKT_MAXAGE=86400 +AUTHTKT_SECRET=aed4ma7pah7Riph9paMoow3raeB5ooSa2ayee4fooQuohT7Etinohshah7eib4Re +AUTHTKT_COOKIENAME=auth_tkt_geoportailv3 +AUTHTKT_HTTP_ONLY=True +AUTHTKT_SECURE=True +AUTHTKT_SAMESITE=Lax +BASICAUTH=False +GEOPORTAL_INTERNAL_URL=http://geoportal:8080 +# For internal print +GEOPORTAL_INTERNAL_HOST=geoportal +GEOPORTAL_INTERNAL_PORT=8080 +TILECLOUDCHAIN_INTERNAL_URL=http://tilecloudchain:8080 +# For internal print +TILECLOUDCHAIN_INTERNAL_HOST=tilecloudchain +TILECLOUDCHAIN_INTERNAL_PORT=8080 +MAPSERVER_URL=http://mapserver:8080/ +TINYOWS_URL=http://tinyows:8080/ +QGISSERVER_URL=http://qgisserver:8080/ +QGIS_VERSION=3.10 +REDIS_HOST=redis +REDIS_PORT=6379 +REDIS_DB=0 +GUNICORN_PARAMS=--bind=:8080 --worker-class=gthread --threads=10 --workers=1 --timeout=60 --max-requests=1000 --max-requests-jitter=100 --config=/etc/gunicorn/config.py +DEVSERVER_HOST=webpack_dev_server:8080 +C2C_REDIS_URL=redis://redis:6379/0 +PGOPTIONS=-c statement_timeout=30000 +CATALINA_OPTS=-Xmx1024m +C2C_BROADCAST_PREFIX=broadcast_geoportal_ +LOG_LEVEL=INFO +C2CGEOPORTAL_LOG_LEVEL=INFO +SQL_LOG_LEVEL=WARN +GUNICORN_LOG_LEVEL=WARN +OTHER_LOG_LEVEL=WARN +DOGPILECACHE_LOG_LEVEL=WARN +LOG_TYPE=console +CPL_VSIL_CURL_USE_CACHE=TRUE +CPL_VSIL_CURL_CACHE_SIZE=128000000 +CPL_VSIL_CURL_USE_HEAD=FALSE +GDAL_DISABLE_READDIR_ON_OPEN=TRUE diff --git a/env.project b/env.project new file mode 100644 index 000000000..8cec478eb --- /dev/null +++ b/env.project @@ -0,0 +1,39 @@ +# Custom project values + +# Database +PGDATABASE=gmf_geoportailv3 +PGSCHEMA=main +PGSCHEMA_STATIC=main_static +# To use the mutualised database. +PGHOST=pg-gs.camptocamp.com +PGHOST_SLAVE=pg-gs.camptocamp.com +PGPORT=30100 +PGPORT_SLAVE=30101 +PGUSER= +PGPASSWORD= +# Should be set to 'prefer' to be able to connect to a local database +PGSSLMODE=require +# To use a database on the host +# PGHOST=172.17.0.1 +# PGHOST_SLAVE=172.17.0.1 +# PGPORT=5432 +# PGUSER=www-data +# PGPASSWORD=www-data +# PGSSLMODE=prefer + +# Use the mutualised print, ask Camptocamp to configure your project. +PRINT_URL=https://mutualized-print.apps.openshift-ch-1.camptocamp.com/print/geoportailv3/ +# To use the internal print: +# PRINT_URL=http://print:8080/print/ + +TILEGENERATION_SQS_QUEUE= +TILEGENERATION_S3_BUCKET= + +# For production +# FRONT_INNER_PORT=80 +# FRONT_CONFIG=haproxy +# For development (front in https) +FRONT_INNER_PORT=443 +FRONT_CONFIG=haproxy_dev + +C2C_SECRET=c2crulez diff --git a/run_alembic.sh b/run_alembic.sh new file mode 100644 index 000000000..fcc36f12d --- /dev/null +++ b/run_alembic.sh @@ -0,0 +1,13 @@ +#!/bin/bash -eu +# Upgrade the DB. +# +# Mostly useful in a Docker environment. + +for ini in *alembic*.ini +do + if [[ -f $ini ]] + then + echo "$ini ===========================" + alembic -c $ini upgrade head + fi +done diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..5eb7a1865 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[flake8] +ignore = E121,E123,E126,E226,E24,E704 +max-line-length = 110 diff --git a/spell-ignore-words.txt b/spell-ignore-words.txt new file mode 100644 index 000000000..2fbe53211 --- /dev/null +++ b/spell-ignore-words.txt @@ -0,0 +1 @@ +oder diff --git a/yamllint.yaml b/yamllint.yaml new file mode 100644 index 000000000..62a4e5b62 --- /dev/null +++ b/yamllint.yaml @@ -0,0 +1,9 @@ +--- +extends: default + +rules: + line-length: + max: 110 + indentation: + spaces: 2 + truthy: disable