From 53c201f94c81922a04b264014c4c29d32551453e Mon Sep 17 00:00:00 2001 From: Martin Lowe <martin.lowe@eclipse-foundation.org> Date: Thu, 9 Jun 2022 11:23:30 -0400 Subject: [PATCH] Update make commands to use templates, made maria optional w/ profile --- Makefile | 6 +-- README.md | 4 +- config/.env.sample | 10 ++-- config/foundationdb/secret.properties.sample | 9 ++-- config/secret.properties.sample | 6 ++- docker-compose.yaml | 56 ++++---------------- 6 files changed, 28 insertions(+), 63 deletions(-) diff --git a/Makefile b/Makefile index 466ac24..9997b25 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ setup:; - test -f ".env" || cp config/.env.sample .env - test -f "./config/secret.properties" || cp config/secret.properties.sample config/secret.properties - test -f "./config/foundationdb/secret.properties" || cp config/foundationdb/secret.properties.sample config/foundationdb/secret.properties \ No newline at end of file + rm .env && envsubst < config/.env.sample > .env + rm ./config/secret.properties && envsubst < config/secret.properties.sample > config/secret.properties + rm ./config/foundationdb/secret.properties && envsubst < config/foundationdb/secret.properties.sample > config/foundationdb/secret.properties \ No newline at end of file diff --git a/README.md b/README.md index e4bcf00..1b8cad6 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ This project uses Quarkus, the Supersonic Subatomic Java Framework. If you want ## Setting up environment -Before running the application, the initial setup should be observed. The initial setup of this server can be started by running the command `make setup` which will instantiate the secrets file and environment hidden file. To finish the setup of the environment file, open it and add values to the missing fields before starting docker for this project. The missing fields are primarily passwords for the various services running in docker for the project. Set them to some values and save the file. Once finished you can run the docker-compose command for this project successfully. +Before running the application, the initial setup should be observed. The initial setup of this server can be started by running the command `make setup` which will instantiate the secrets file and environment hidden file. To finish the setup of the environment file, open it and add values to the missing fields before starting docker for this project. The missing fields are primarily passwords for the various services running in docker for the project. Set them to some values and save the file. Once finished you can run the docker-compose command for this project successfully. If you need to start MariaDB (not using a shared volume) you can use `docker-compose --profile full up` to start MariaDB along with other services. -Additionally, some of the values in the .env file will need to be set into the secret.properties files in `./config/secret.properties` and `./config/foundationdb/secret.properties`. The value for `WGAPI_MYSQL_PASSWORD` will need to be set as the value for the `quarkus.datasource.password` property in both files. This will give the applications access to make changes to the databases. +Additionally, some of the values in the .env file will need to be set into the secret.properties files in `./config/secret.properties` and `./config/foundationdb/secret.properties`. The value for `WGAPI_MYSQL_PASSWORD` will need to be set as the value for the `quarkus.datasource.password` property in both files. This will give the applications access to make changes to the databases. Once the stack is running, navigate to http://localhost:8080 and log into Keycloak using the credentials set in the `.env` file. Upon logging in in the top left corner, if the text says `Master`, then hover over the text and select `Foundation` in the pop up that appears below the text. This switches your realm to the one configured at boot time by the embedded configuration files. In the left hand menu, select `Clients` and open the `foundation` client by clicking on the name of the client. Once here, navigate to the `Credentials` tab and regenerate the secret. That text will be the value of the `quarkus.oidc.credentials.client-secret.value` property in the `./config/foundationdb/secret.properties` file. Do the same thing for the `working_groups_api` client, instead setting the value of `quarkus.oidc.credentials.secret` property in the `./config/secret.properties` file. diff --git a/config/.env.sample b/config/.env.sample index 07c010c..b22b1d4 100644 --- a/config/.env.sample +++ b/config/.env.sample @@ -1,7 +1,3 @@ -WGAPI_MYSQL_PASSWORD= -WGAPI_POSTGRES_DB=ef_wgapi -WGAPI_POSTGRES_USER=root -WGAPI_POSTGRES_PASSWORD= -WGAPI_KEYCLOAK_USER=admin -WGAPI_KEYCLOAK_PASSWORD= -CONFIG_SECRET_PATH=/localdev/eclipsefdn-working-groups-api/config/secret.properties \ No newline at end of file +WGAPI_MYSQL_PASSWORD=$MYSQL_PASSWORD +WGAPI_MYSQL_PORT=3306 +CONFIG_SECRET_PATH=$PWD/config/secret.properties \ No newline at end of file diff --git a/config/foundationdb/secret.properties.sample b/config/foundationdb/secret.properties.sample index 41c9003..9b86eb8 100644 --- a/config/foundationdb/secret.properties.sample +++ b/config/foundationdb/secret.properties.sample @@ -1,9 +1,8 @@ +quarkus.datasource.jdbc.url=jdbc:mariadb://localhost:$FOUNDATIONDB_DB_PORT/$FOUNDATIONDB_DB_NAME +quarkus.datasource.username=$MYSQL_USER +quarkus.datasource.password=$MYSQL_PASSWORD -quarkus.datasource.jdbc.url = jdbc:mariadb://mariadb/efclone -quarkus.datasource.username = root -quarkus.datasource.password = sample - -quarkus.oauth2.introspection-url=http://keycloak/auth/realms/foundation +quarkus.oauth2.introspection-url=http://localhost:8080/auth/realms/foundation quarkus.oauth2.client-id=foundation quarkus.oauth2.client-secret=sample diff --git a/config/secret.properties.sample b/config/secret.properties.sample index 22c0dc6..fbf2905 100644 --- a/config/secret.properties.sample +++ b/config/secret.properties.sample @@ -1,3 +1,7 @@ quarkus.oidc.auth-server-url=http://keycloak/auth/realms/foundation quarkus.oidc.client-id=working_groups_api -quarkus.oidc.credentials.secret=sample \ No newline at end of file +quarkus.oidc.credentials.secret=sample + +# +# +# \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 9cb1088..6a2c57d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -21,19 +21,7 @@ services: cpus: '0.001' memory: 128M depends_on: - - mariadb - foundationdb - mariadb: - image: mariadb:latest - command: --max_allowed_packet=100000000 - ports: - - '3306:3306' - environment: - MYSQL_ROOT_PASSWORD: ${WGAPI_MYSQL_PASSWORD} - MYSQL_DATABASE: working_groups_api - volumes: - - ./config/mariadb/init.sql:/docker-entrypoint-initdb.d/init.sql - - ./volumes/mariadb:/var/lib/mysql foundationdb: image: eclipsefdn/foundationdb-api:production-b43bc82-7 ports: @@ -53,38 +41,16 @@ services: reservations: cpus: '0.001' memory: 256M - depends_on: - - mariadb - - keycloak - postgres: - image: postgres:12.4 - volumes: - - ./volumes/postgres:/var/lib/postgresql/data - environment: - - POSTGRES_DB=${WGAPI_POSTGRES_DB} - - POSTGRES_USER=${WGAPI_POSTGRES_USER} - - POSTGRES_PASSWORD=${WGAPI_POSTGRES_PASSWORD} + mariadb: + image: mariadb:latest + command: --max_allowed_packet=100000000 + profiles: + - full ports: - - 5432 - keycloak: - image: jboss/keycloak:11.0.1 - volumes: - - ./config/keycloak/:/opt/jboss/keycloak/imports/ - command: - - "-b 0.0.0.0 -Dkeycloak.import=/opt/jboss/keycloak/imports/realm-export.json" + - "${WGAPI_MYSQL_PORT:-3306}:3306" environment: - - VIRTUAL_HOST=keycloak - - VIRTUAL_PORT=8080 - - DB_VENDOR=POSTGRES - - DB_DATABASE=${WGAPI_POSTGRES_DB} - - DB_SCHEMA=public - - DB_ADDR=postgres - - DB_PORT=5432 - - DB_USER=${WGAPI_POSTGRES_USER} - - DB_PASSWORD=${WGAPI_POSTGRES_PASSWORD} - - KEYCLOAK_USER=${WGAPI_KEYCLOAK_USER} - - KEYCLOAK_PASSWORD=${WGAPI_KEYCLOAK_PASSWORD} - ports: - - '8080:8080' - depends_on: - - postgres \ No newline at end of file + MYSQL_ROOT_PASSWORD: ${WGAPI_MYSQL_PASSWORD} + MYSQL_DATABASE: working_groups_api + volumes: + - ./config/mariadb/init.sql:/docker-entrypoint-initdb.d/init.sql + - ./volumes/mariadb:/var/lib/mysql \ No newline at end of file -- GitLab