From efb824d0ba664a4a0735ba751806df3391e2f92d Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 16 Jan 2025 15:03:22 +0100 Subject: [PATCH] add several Spring profiles and Spring profile documentation --- README.md | 34 ++++++++++++++++++++++++++++++ src/main/resources/application.yml | 29 +++++++++++++++++++++---- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e9f40f79..23ae7758 100644 --- a/README.md +++ b/README.md @@ -622,6 +622,40 @@ also try this (assumed you've sourced .aliases): howto ``` +### How to Run the Application With Other Profiles, e.g. production: + +Add `--args='--spring.profiles.active=...` with the wanted profile selector: + +```sh +gw bootRun --args='--spring.profiles.active=prod' +``` + +Currently, the difference between 'dev' and 'prod' is only that 'dev' creates the PostgreSQL users, +and 'prod' expects these to be already created in the + +All other differences are currently controlled by environment-variables. + + +### How to Do a Clean Run of the Application + +If you frequently need to run with a fresh database and a clean build, you can use this: + +```sh +gw clean && pg-sql-reset && sleep 5 && gw bootRun --args='--spring.profiles.active=dev-office' 2>&1 | tee log +``` + + +### How to Run Just the Office Module (including dependents): + +At the end of `src/main/resources/application.yml` you can find customized profiles between the sections separated by `---`. + +For example for a dev environment, run: + +```sh +gw bootRun --args='--spring.profiles.active=dev-office' +``` + + ### How to Configure .pgpass for the Default PostgreSQL Database? To access the default database schema as used during development, add this line to your `.pgpass` file in your users home directory: diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1ea27053..4943eb60 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -46,7 +46,8 @@ spring: dialect: net.hostsharing.hsadminng.config.PostgresCustomDialect liquibase: - contexts: default,dev,office,pg_stat_statements # default just as a marker to show from which profile it comes + # default just as a marker to show from which profile it comes + contexts: default,dev,rbac-test,office,office-test,booking,booking-test,hosting,hosting-test,pg_stat_statements # keep this in sync with test/.../application.yml springdoc: @@ -68,7 +69,7 @@ metrics: --- -# the 'dev-all' profile automatically creates the PgSql users and runs only the office module +# the 'dev-all' profile automatically creates the PgSql users and runs all modules without test-data spring: config: activate: @@ -78,7 +79,17 @@ spring: --- -# the 'dev-office' profile automatically creates the PgSql users and runs only the office module +# the 'dev-all' profile automatically creates the PgSql users and runs all modules with test-data +spring: + config: + activate: + on-profile: dev-all-test + liquibase: + contexts: dev,rbac-test,office,office-test,booking,booking-test,hosting,hosting-test,pg_stat_statements + +--- + +# the 'dev-office' profile automatically creates the PgSql users and runs only the office module without test-data spring: config: activate: @@ -88,7 +99,17 @@ spring: --- -# the 'prod-office' profile expects that the PgSql users are already created and runs only the office module +# the 'dev-office' profile automatically creates the PgSql users and runs only the office module with test-data +spring: + config: + activate: + on-profile: dev-office-test + liquibase: + contexts: dev,rbac-test,office,office-test,pg_stat_statements + +--- + +# the 'prod-office' profile expects that the PgSql users are already created and runs only the office module without test-data spring: config: activate: