From b028e5ce61a24379bb4d419b2c84a87f963f705f Mon Sep 17 00:00:00 2001 From: Martin Lowe Date: Thu, 2 Jun 2022 10:05:21 -0400 Subject: [PATCH 1/3] Add local build infra along with a setup script --- .gitignore | 1 + Makefile | 9 +++++++ docker-compose.yaml | 61 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 Makefile create mode 100644 docker-compose.yaml diff --git a/.gitignore b/.gitignore index 91e922f..da16a85 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ nb-configuration.xml *.rej # Local environment +/volumes .env /node_modules diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f8101ab --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +setup:; + test -f ".env" || printf "WGAPI_MYSQL_PASSWORD=eclipse_changeme\n \ + WGAPI_POSTGRES_DB=ef_wgapi\n \ + WGAPI_POSTGRES_USER=root\n \ + WGAPI_POSTGRES_PASSWORD=eclipse_changeme\n \ + WGAPI_KEYCLOAK_USER=admin\n \ + WGAPI_KEYCLOAK_PASSWORD=eclipse_changeme\n \ + CONFIG_SECRET_PATH=$PWD/config/secret.properties" > .env + test -f "./config/secret.properties" || cp config/secret.properties.sample config/secret.properties \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..792c6b2 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,61 @@ +version: '3' +services: + application: + build: + dockerfile: ./src/main/docker/Dockerfile.jvm + ports: + - 8090:8090 + environment: + - CONFIG_SECRET_PATH=/var/run/secrets/secret.properties + volumes: + - ./config/secret.properties:/var/run/secrets/secret.properties + deploy: + restart_policy: + condition: on-failure + max_attempts: 5 + resources: + limits: + cpus: '0.5' + memory: 256M + reservations: + cpus: '0.001' + memory: 192M + 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 + 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} + ports: + - 5432 + keycloak: + image: jboss/keycloak:11.0.1 + 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 -- GitLab From 70a865d17d6a2b36d3f06292a7e78d8b7877cbd2 Mon Sep 17 00:00:00 2001 From: Martin Lowe Date: Mon, 6 Jun 2022 11:48:07 -0400 Subject: [PATCH 2/3] Update for build to strip out passwords from sample env file Additionally updated docs to prompt user to update password before start --- Makefile | 8 +------- README.md | 16 +++++++++------- config/.env.sample | 7 +++++++ 3 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 config/.env.sample diff --git a/Makefile b/Makefile index f8101ab..9b177e6 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,3 @@ setup:; - test -f ".env" || printf "WGAPI_MYSQL_PASSWORD=eclipse_changeme\n \ - WGAPI_POSTGRES_DB=ef_wgapi\n \ - WGAPI_POSTGRES_USER=root\n \ - WGAPI_POSTGRES_PASSWORD=eclipse_changeme\n \ - WGAPI_KEYCLOAK_USER=admin\n \ - WGAPI_KEYCLOAK_PASSWORD=eclipse_changeme\n \ - CONFIG_SECRET_PATH=$PWD/config/secret.properties" > .env + test -f ".env" || cp config/.env.sample .env test -f "./config/secret.properties" || cp config/secret.properties.sample config/secret.properties \ No newline at end of file diff --git a/README.md b/README.md index 057a8c5..dd9e8b3 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,16 @@ # eclipsefdn-working-group-api Project -This project uses Quarkus, the Supersonic Subatomic Java Framework. +This project uses Quarkus, the Supersonic Subatomic Java Framework. If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . -If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . +## 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. ## Running the application in dev mode You can run your application in dev mode that enables live coding using: ```shell script -./mvnw compile quarkus:dev +mvn compile quarkus:dev ``` > **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/. @@ -17,7 +19,7 @@ You can run your application in dev mode that enables live coding using: The application can be packaged using: ```shell script -./mvnw package +mvn package ``` It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory. Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory. @@ -26,7 +28,7 @@ The application is now runnable using `java -jar target/quarkus-app/quarkus-run. If you want to build an _über-jar_, execute the following command: ```shell script -./mvnw package -Dquarkus.package.type=uber-jar +mvn package -Dquarkus.package.type=uber-jar ``` The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`. @@ -35,12 +37,12 @@ The application, packaged as an _über-jar_, is now runnable using `java -jar ta You can create a native executable using: ```shell script -./mvnw package -Pnative +mvn package -Pnative ``` Or, if you don't have GraalVM installed, you can run the native executable build in a container using: ```shell script -./mvnw package -Pnative -Dquarkus.native.container-build=true +mvn package -Pnative -Dquarkus.native.container-build=true ``` You can then execute your native executable with: `./target/eclipsefdn-working-group-api-1.0.0-SNAPSHOT-runner` diff --git a/config/.env.sample b/config/.env.sample new file mode 100644 index 0000000..07c010c --- /dev/null +++ b/config/.env.sample @@ -0,0 +1,7 @@ +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 -- GitLab From c0d778a255e29f58a8e479fdcd7dc3bbd2e7547f Mon Sep 17 00:00:00 2001 From: Martin Lowe Date: Mon, 6 Jun 2022 11:48:29 -0400 Subject: [PATCH 3/3] Update build to disable oauth as it is not currently in use --- .gitignore | 1 + docker-compose.yaml | 4 ++-- src/main/resources/application.properties | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index da16a85..8861b7c 100644 --- a/.gitignore +++ b/.gitignore @@ -39,5 +39,6 @@ nb-configuration.xml /volumes .env +/config/**/*secret.properties /node_modules /src/test/resources/schemas \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 792c6b2..0a2842f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,10 +16,10 @@ services: resources: limits: cpus: '0.5' - memory: 256M + memory: 192M reservations: cpus: '0.001' - memory: 192M + memory: 128M mariadb: image: mariadb:latest command: --max_allowed_packet=100000000 diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e69de29..7f6dfba 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -0,0 +1,2 @@ +quarkus.oauth.enabled=false +quarkus.oidc.enabled=false \ No newline at end of file -- GitLab