diff --git a/Makefile b/Makefile index 466ac2447cf06d4f95cc60e0a77cace3efa9f134..9997b25132787b2d17083ef929c0cc312367a8a7 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 e4bcf00af694e308f7a881abcbc4ac10ef630af7..1b8cad6958fda85fa479534bdc2c01841649336f 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 07c010cc829c4e02b56e7e536601b30eb85898dc..b22b1d4ea4b5cb65fb110115f3968333113f5be1 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 41c90031c8448c09277461ba1c70a18416cfbf6c..9b86eb8eef85d2450b4026beb52695d9ce8f5124 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 22c0dc6ec916ae89efc1f206b52f0ef8a8551ef3..fbf2905808813fea3dd7e5b17a27119331cf7003 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 9cb1088711ddccc88aa0cadc13d669b6ae1f41b8..6a2c57d693fbf2035d73f2c5f6585f7b2251a59a 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