From f74607e1424a3eb188c9bb7d5d0270007848eed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Tue, 1 Oct 2024 06:44:10 +0000 Subject: [PATCH] Upgrade to GeoMapFish 2.9 --- CONST_create_template/Makefile | 2 +- .../docker-compose.override.sample.yaml | 4 +-- CONST_create_template/scripts/db-backup | 25 +++++++++++++++++-- CONST_create_template/scripts/db-restore | 25 +++++++++++++++++-- CONST_create_template/tests/test_testapp.py | 2 +- Makefile | 2 +- docker-compose.override.sample.yaml | 15 +++++++++++ .../static/story-map.html | 2 +- scripts/db-backup | 25 +++++++++++++++++-- scripts/db-restore | 25 +++++++++++++++++-- 10 files changed, 113 insertions(+), 14 deletions(-) diff --git a/CONST_create_template/Makefile b/CONST_create_template/Makefile index 38318f18f..557b16392 100644 --- a/CONST_create_template/Makefile +++ b/CONST_create_template/Makefile @@ -61,7 +61,7 @@ acceptance-init: ## Initialize the acceptance tests docker compose exec -T tools wait-db docker compose exec -T tools psql --command="DROP EXTENSION IF EXISTS postgis CASCADE" scripts/db-restore --docker-compose-file=docker-compose.yaml --docker-compose-file=docker-compose-db.yaml \ - --arg=--clean --arg=--if-exists --arg=--verbose $(DUMP_FILE) + --arg=--clean --arg=--if-exists --arg=--verbose $(DUMP_FILE) || true docker compose --file=docker-compose.yaml --file=docker-compose-db.yaml up -d .PHONY: acceptance diff --git a/CONST_create_template/docker-compose.override.sample.yaml b/CONST_create_template/docker-compose.override.sample.yaml index 1eabba3b2..c70e4d5ed 100644 --- a/CONST_create_template/docker-compose.override.sample.yaml +++ b/CONST_create_template/docker-compose.override.sample.yaml @@ -50,8 +50,8 @@ services: # # Adapt the path for ngeo / gmf contrib to point where you have checkouted the code. # # volumes: # # - ./geoportal/${PACKAGE}_geoportal/static-ngeo:/app/${PACKAGE}_geoportal/static-ngeo - # # - ./../ngeo/src:/usr/lib/node_modules/ngeo/src - # # - ./../ngeo/contribs:/usr/lib/node_modules/ngeo/contribs + # # - ./../ngeo/src:/opt/c2cgeoportal/geoportal/node_modules/ngeo/src + # # - ./../ngeo/contribs:/opt/c2cgeoportal/geoportal/node_modules/ngeo/contribs # volumes_from: # - config:rw # extends: diff --git a/CONST_create_template/scripts/db-backup b/CONST_create_template/scripts/db-backup index be1d5001b..2de72117d 100755 --- a/CONST_create_template/scripts/db-backup +++ b/CONST_create_template/scripts/db-backup @@ -37,6 +37,10 @@ import sys def main() -> None: """Backup the database.""" parser = argparse.ArgumentParser(description="Backup the database.") + parser.add_argument("--verbose", action="store_true", help="Print the command that is executed.") + parser.add_argument( + "--dry-run", action="store_true", help="Only print the command that would be executed." + ) parser.add_argument( "--env", default=".env", @@ -83,7 +87,20 @@ def main() -> None: "--dbname={}".format(env["PGDATABASE"]), *args.arg, ] - print(shlex.join([*command1, *command2_annon, *command3])) + if args.dry_run or args.verbose: + subprocess.run( + [ + "docker", + "run", + "--rm", + "camptocamp/postgres:{}".format(env["POSTGRES_TAG"]), + "pg_dump", + "--version", + ] + ) + print(shlex.join([*command1, *command2_annon, *command3])) + if args.dry_run: + sys.exit(0) sys.exit(subprocess.run([*command1, *command2, *command3], stdout=file_out).returncode) else: command = [ @@ -97,7 +114,11 @@ def main() -> None: 'pg_dump --format=c --dbname="$PGDATABASE"', *args.arg, ] - print(shlex.join(command)) + if args.dry_run or args.verbose: + subprocess.run(["docker", "compose", "exec", "tools", "pg_dump", "--version"]) + print(shlex.join(command)) + if args.dry_run: + sys.exit(0) sys.exit(subprocess.run(command, stdout=file_out).returncode) diff --git a/CONST_create_template/scripts/db-restore b/CONST_create_template/scripts/db-restore index 80168acf7..dee0f088f 100755 --- a/CONST_create_template/scripts/db-restore +++ b/CONST_create_template/scripts/db-restore @@ -36,6 +36,10 @@ import sys def main() -> None: """Restore the database backup.""" parser = argparse.ArgumentParser(description="Restore the database backup.") + parser.add_argument("--verbose", action="store_true", help="Print the command that is executed.") + parser.add_argument( + "--dry-run", action="store_true", help="Only print the command that would be executed." + ) parser.add_argument( "--env", help="The env file to use to get the connection settings, by default we log in the composition to " @@ -89,7 +93,20 @@ def main() -> None: "--dbname={}".format(env["PGDATABASE"]), *args.arg, ] - print(shlex.join([*command1, *command2_annon, *command3])) + if args.verbose or args.dry_run: + subprocess.run( + [ + "docker", + "run", + "--rm", + "camptocamp/postgres:{}".format(env["POSTGRES_TAG"]), + "pg_restore", + "--version", + ] + ) + print(shlex.join([*command1, *command2_annon, *command3])) + if args.dry_run: + sys.exit(0) sys.exit(subprocess.run([*command1, *command2, *command3], stdin=file_in).returncode) else: command = [ @@ -103,7 +120,11 @@ def main() -> None: "-c", 'pg_restore --dbname="$PGDATABASE" ' + " ".join(args.arg), ] - print(shlex.join(command)) + if args.verbose or args.dry_run: + subprocess.run(["docker", "compose", "exec", "tools", "pg_restore", "--version"]) + print(shlex.join(command)) + if args.dry_run: + sys.exit(0) sys.exit(subprocess.run(command, stdin=file_in).returncode) diff --git a/CONST_create_template/tests/test_testapp.py b/CONST_create_template/tests/test_testapp.py index aad6500ef..1b87be341 100644 --- a/CONST_create_template/tests/test_testapp.py +++ b/CONST_create_template/tests/test_testapp.py @@ -34,7 +34,7 @@ def test_desktop_alt(url: str) -> None: assert response.status_code == 200, response.text assert re.search( - r'', + r'', response.text, ), response.text assert re.search(r'//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/${PACKAGE}_geoportal/static-ngeo:/app/${PACKAGE}_geoportal/static-ngeo + # # - ./../ngeo/src:/opt/c2cgeoportal/geoportal/node_modules/ngeo/src + # # - ./../ngeo/contribs:/opt/c2cgeoportal/geoportal/node_modules/ngeo/contribs + # volumes_from: + # - config:rw + # extends: + # file: docker-compose-lib.yaml + # service: webpack_dev_server + tilecloudchain: # volumes: # - ../tilecloud-chain/tilecloud_chain:/app/tilecloud_chain diff --git a/geoportal/geomapfish_geoportal/static/story-map.html b/geoportal/geomapfish_geoportal/static/story-map.html index e2dc02a5d..baea3b09d 100644 --- a/geoportal/geomapfish_geoportal/static/story-map.html +++ b/geoportal/geomapfish_geoportal/static/story-map.html @@ -13,7 +13,7 @@ /> diff --git a/scripts/db-backup b/scripts/db-backup index be1d5001b..2de72117d 100755 --- a/scripts/db-backup +++ b/scripts/db-backup @@ -37,6 +37,10 @@ import sys def main() -> None: """Backup the database.""" parser = argparse.ArgumentParser(description="Backup the database.") + parser.add_argument("--verbose", action="store_true", help="Print the command that is executed.") + parser.add_argument( + "--dry-run", action="store_true", help="Only print the command that would be executed." + ) parser.add_argument( "--env", default=".env", @@ -83,7 +87,20 @@ def main() -> None: "--dbname={}".format(env["PGDATABASE"]), *args.arg, ] - print(shlex.join([*command1, *command2_annon, *command3])) + if args.dry_run or args.verbose: + subprocess.run( + [ + "docker", + "run", + "--rm", + "camptocamp/postgres:{}".format(env["POSTGRES_TAG"]), + "pg_dump", + "--version", + ] + ) + print(shlex.join([*command1, *command2_annon, *command3])) + if args.dry_run: + sys.exit(0) sys.exit(subprocess.run([*command1, *command2, *command3], stdout=file_out).returncode) else: command = [ @@ -97,7 +114,11 @@ def main() -> None: 'pg_dump --format=c --dbname="$PGDATABASE"', *args.arg, ] - print(shlex.join(command)) + if args.dry_run or args.verbose: + subprocess.run(["docker", "compose", "exec", "tools", "pg_dump", "--version"]) + print(shlex.join(command)) + if args.dry_run: + sys.exit(0) sys.exit(subprocess.run(command, stdout=file_out).returncode) diff --git a/scripts/db-restore b/scripts/db-restore index 80168acf7..dee0f088f 100755 --- a/scripts/db-restore +++ b/scripts/db-restore @@ -36,6 +36,10 @@ import sys def main() -> None: """Restore the database backup.""" parser = argparse.ArgumentParser(description="Restore the database backup.") + parser.add_argument("--verbose", action="store_true", help="Print the command that is executed.") + parser.add_argument( + "--dry-run", action="store_true", help="Only print the command that would be executed." + ) parser.add_argument( "--env", help="The env file to use to get the connection settings, by default we log in the composition to " @@ -89,7 +93,20 @@ def main() -> None: "--dbname={}".format(env["PGDATABASE"]), *args.arg, ] - print(shlex.join([*command1, *command2_annon, *command3])) + if args.verbose or args.dry_run: + subprocess.run( + [ + "docker", + "run", + "--rm", + "camptocamp/postgres:{}".format(env["POSTGRES_TAG"]), + "pg_restore", + "--version", + ] + ) + print(shlex.join([*command1, *command2_annon, *command3])) + if args.dry_run: + sys.exit(0) sys.exit(subprocess.run([*command1, *command2, *command3], stdin=file_in).returncode) else: command = [ @@ -103,7 +120,11 @@ def main() -> None: "-c", 'pg_restore --dbname="$PGDATABASE" ' + " ".join(args.arg), ] - print(shlex.join(command)) + if args.verbose or args.dry_run: + subprocess.run(["docker", "compose", "exec", "tools", "pg_restore", "--version"]) + print(shlex.join(command)) + if args.dry_run: + sys.exit(0) sys.exit(subprocess.run(command, stdin=file_in).returncode)