From df300e1b6d05a6c79d7f4d86c29087d696047f79 Mon Sep 17 00:00:00 2001 From: Bastiaan Date: Fri, 10 Nov 2023 16:11:51 +0100 Subject: [PATCH 1/6] downstream trigger added for appserver, however since there is no personal access token this will fail --- .github/workflows/main.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 94bcbb137..70834f2f1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -203,6 +203,18 @@ jobs: org.opencontainers.image.vendor=RADAR-base org.opencontainers.image.licenses=Apache-2.0 + - name: Trigger downstream repo (appserver) + if: github.event_name != 'pull_request' #only after a merge + uses: convictional/trigger-workflow-and-wait@v1.6.1 + with: + owner: RADAR-base + repo: RADAR-Appserver + github_token: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }} #token with repo access to app_server + workflow_file_name: downstream.yml + ref: dev + propagate_failure: false + wait_workflow: false + # # placeholder for testing # - name: End to end tests (docker image) # id: e2e-prod-docker From 6eeae37b49493587e53e750d8f7cc774973633bd Mon Sep 17 00:00:00 2001 From: Bastiaan Date: Fri, 10 Nov 2023 16:20:33 +0100 Subject: [PATCH 2/6] set the trigger to fire for the testing branch and also without the condition ("if pullrequest") for testing. revert this later --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 70834f2f1..e0da64a3d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -204,14 +204,14 @@ jobs: org.opencontainers.image.licenses=Apache-2.0 - name: Trigger downstream repo (appserver) - if: github.event_name != 'pull_request' #only after a merge + # if: github.event_name != 'pull_request' #only after a merge uses: convictional/trigger-workflow-and-wait@v1.6.1 with: owner: RADAR-base repo: RADAR-Appserver github_token: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }} #token with repo access to app_server workflow_file_name: downstream.yml - ref: dev + ref: downstream-e2e-testing propagate_failure: false wait_workflow: false From 504076cbd8bc1107af612c07521c8ff0ecd52d90 Mon Sep 17 00:00:00 2001 From: Bastiaan Date: Wed, 22 Nov 2023 21:49:14 +0100 Subject: [PATCH 3/6] change access token --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e0da64a3d..d063ae4d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -209,7 +209,7 @@ jobs: with: owner: RADAR-base repo: RADAR-Appserver - github_token: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }} #token with repo access to app_server + github_token: ${{ secrets.APPSERVER_REPO_PERSONAL_ACCESS_TOKEN }} #token with repo access to app_server workflow_file_name: downstream.yml ref: downstream-e2e-testing propagate_failure: false From 110a2f546c8684a0f94f9d0861e6fd14741536c2 Mon Sep 17 00:00:00 2001 From: Bastiaan Date: Wed, 22 Nov 2023 22:01:06 +0100 Subject: [PATCH 4/6] change personal access token --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d063ae4d9..4b1668665 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -207,11 +207,11 @@ jobs: # if: github.event_name != 'pull_request' #only after a merge uses: convictional/trigger-workflow-and-wait@v1.6.1 with: - owner: RADAR-base + owner: yatharthranjan repo: RADAR-Appserver github_token: ${{ secrets.APPSERVER_REPO_PERSONAL_ACCESS_TOKEN }} #token with repo access to app_server workflow_file_name: downstream.yml - ref: downstream-e2e-testing + ref: origin/downstream-e2e-testing propagate_failure: false wait_workflow: false From ec84e0a33ec180d1c396375842c9d47f648976a8 Mon Sep 17 00:00:00 2001 From: Yatharth Ranjan Date: Thu, 23 Nov 2023 17:13:28 +0000 Subject: [PATCH 5/6] fix appserver ref --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4b1668665..a54cd883c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -211,7 +211,7 @@ jobs: repo: RADAR-Appserver github_token: ${{ secrets.APPSERVER_REPO_PERSONAL_ACCESS_TOKEN }} #token with repo access to app_server workflow_file_name: downstream.yml - ref: origin/downstream-e2e-testing + ref: downstream_e2e_testing propagate_failure: false wait_workflow: false From ede87809b663b613ccb47dd01e40d406041d4698 Mon Sep 17 00:00:00 2001 From: Bastiaan Date: Fri, 24 Nov 2023 13:25:54 +0100 Subject: [PATCH 6/6] reorganize the docker stacks a bit, with some comments on how to use --- .github/workflows/main.yml | 18 +++-------- Dockerfile | 2 ++ README.md | 7 ++--- src/main/docker/app.yml | 21 ------------- src/main/docker/management-portal.yml | 30 ++++++++----------- .../docker/mp_dockerhub/docker-compose.yml | 25 ++++++++++++++++ src/main/docker/mp_local/docker-compose.yml | 17 +++++++++++ src/main/docker/mysql.yml | 4 +-- src/main/docker/non_mp/docker-compose.yml | 15 ++++++++++ src/main/docker/postgresql.yml | 4 +-- .../docker/{docker-compose.yml => smtp.yml} | 12 ++------ src/main/docker/sonar.yml | 6 ++-- 12 files changed, 88 insertions(+), 73 deletions(-) delete mode 100644 src/main/docker/app.yml create mode 100644 src/main/docker/mp_dockerhub/docker-compose.yml create mode 100644 src/main/docker/mp_local/docker-compose.yml create mode 100644 src/main/docker/non_mp/docker-compose.yml rename src/main/docker/{docker-compose.yml => smtp.yml} (59%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a54cd883c..3db1c4a4e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -204,27 +204,17 @@ jobs: org.opencontainers.image.licenses=Apache-2.0 - name: Trigger downstream repo (appserver) - # if: github.event_name != 'pull_request' #only after a merge + if: github.event_name != 'pull_request' #only after a merge uses: convictional/trigger-workflow-and-wait@v1.6.1 with: - owner: yatharthranjan + owner: RADAR-base repo: RADAR-Appserver github_token: ${{ secrets.APPSERVER_REPO_PERSONAL_ACCESS_TOKEN }} #token with repo access to app_server - workflow_file_name: downstream.yml - ref: downstream_e2e_testing + workflow_file_name: main.yml + ref: master #change for testing against a specific downstream branch propagate_failure: false wait_workflow: false -# # placeholder for testing -# - name: End to end tests (docker image) -# id: e2e-prod-docker -# run: | -# cp src/test/resources/config/keystore.p12 src/main/docker/etc/config -# ./gradlew -Pprod buildDocker -x test -x javadocJar -# docker-compose -f src/main/docker/app.yml up -d -# yarn run e2e-prod -# docker-compose -f src/main/docker/app.yml down -v - # Temp fix # https://github.com/docker/build-push-action/issues/252 # https://github.com/moby/buildkit/issues/1896 diff --git a/Dockerfile b/Dockerfile index 0065916e3..f2313270f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +#this dockerfile is used in the github actions workflows + # Build stage FROM --platform=$BUILDPLATFORM eclipse-temurin:17-jdk as builder diff --git a/README.md b/README.md index ee9c92467..97720eab7 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ docker-compose files. ```shell keytool -genkeypair -alias radarbase-managementportal-ec -keyalg EC -validity 3650 -keysize 256 -sigalg SHA256withECDSA -storetype PKCS12 -keystore src/main/docker/etc/config/keystore.p12 -storepass radarbase -keypass radarbase ``` -3. Now, we can start the stack with `docker-compose -f src/main/docker/management-portal.yml up -d`. +3. Now, we can start the stack with `docker-compose -f src/main/docker/mp_dockerhub/docker-compose.yml up -d`. This will start a Postgres database and ManagementPortal. The default password for the `admin` account is `admin`. An angular live development server to access the managementportal can be started using the `yarn start` command (see [Development](#development)). @@ -78,8 +78,6 @@ memory database and ManagementPortal. An angular live development server to acce | Demo data loaded | Yes | No | - - The docker image can be pulled by running `docker pull radarbase/management-portal:latest`. ## Configuration @@ -276,6 +274,7 @@ will generate few files: To optimize the ManagementPortal application for production, run: ./gradlew -Pprod clean bootWar + ### Hosting in production The latest Meta-QR code implementation requires REST resources on `api/meta-token/*` should definitely be rate-limited by upstream servers. @@ -331,7 +330,7 @@ To achieve this, first build a docker image of your app by running: Then run: - docker-compose -f src/main/docker/app.yml up -d + docker-compose -f src/main/docker/mp_local/docker-compose.yml up -d For more information refer to [Using Docker and Docker-Compose][], this page also contains information on the docker-compose sub-generator (`yo jhipster:docker-compose`), which is able to generate docker configurations for one or several JHipster applications. ## Documentation diff --git a/src/main/docker/app.yml b/src/main/docker/app.yml deleted file mode 100644 index 45b6da05b..000000000 --- a/src/main/docker/app.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: '2' -services: - managementportal-app: - image: managementportal - environment: - - SPRING_PROFILES_ACTIVE=prod,api-docs - - SPRING_DATASOURCE_URL=jdbc:postgresql://managementportal-postgresql:5432/managementportal - - SPRING_DATASOURCE_USERNAME=radarbase - - SPRING_DATASOURCE_PASSWORD=radarbase - - SPRING_LIQUIBASE_CONTEXTS=dev #includes testing_data, remove for production builds - - MANAGEMENTPORTAL_FRONTEND_CLIENT_SECRET=secret - - JHIPSTER_SLEEP=10 # gives time for the database to boot before the application - - JAVA_OPTS=-Xmx512m # maximum heap size for the JVM running ManagementPortal, increase this as necessary - ports: - - 8080:8080 - volumes: - - ./etc:/mp-includes - managementportal-postgresql: - extends: - file: postgresql.yml - service: managementportal-postgresql diff --git a/src/main/docker/management-portal.yml b/src/main/docker/management-portal.yml index 7ea6fc1c4..dc5488725 100644 --- a/src/main/docker/management-portal.yml +++ b/src/main/docker/management-portal.yml @@ -1,20 +1,16 @@ version: '2' services: managementportal-app: - image: radarbase/management-portal - environment: - - SPRING_PROFILES_ACTIVE=prod,api-docs - - SPRING_DATASOURCE_URL=jdbc:postgresql://managementportal-postgresql:5432/managementportal - - SPRING_DATASOURCE_USERNAME=radarbase - - SPRING_DATASOURCE_PASSWORD=radarbase - - MANAGEMENTPORTAL_FRONTEND_CLIENT_SECRET=secret - - JHIPSTER_SLEEP=10 # gives time for the database to boot before the application - - JAVA_OPTS=-Xmx512m # maximum heap size for the JVM running ManagementPortal, increase this as necessary - ports: - - 8080:8080 - volumes: - - ./etc:/mp-includes - managementportal-postgresql: - extends: - file: postgresql.yml - service: managementportal-postgresql + image: radarbase/management-portal + environment: + - SPRING_PROFILES_ACTIVE=prod,api-docs + - SPRING_DATASOURCE_URL=jdbc:postgresql://managementportal-postgresql:5432/managementportal + - SPRING_DATASOURCE_USERNAME=radarbase + - SPRING_DATASOURCE_PASSWORD=radarbase + - MANAGEMENTPORTAL_FRONTEND_CLIENT_SECRET=secret + - JHIPSTER_SLEEP=10 # gives time for the database to boot before the application + - JAVA_OPTS=-Xmx512m # maximum heap size for the JVM running ManagementPortal, increase this as necessary + ports: + - "8080:8080" + volumes: + - ./etc:/mp-includes diff --git a/src/main/docker/mp_dockerhub/docker-compose.yml b/src/main/docker/mp_dockerhub/docker-compose.yml new file mode 100644 index 000000000..cb480776a --- /dev/null +++ b/src/main/docker/mp_dockerhub/docker-compose.yml @@ -0,0 +1,25 @@ +# Docker stack to run managementport using only dockerhub images + +version: '2.1' + +networks: + mail: + driver: bridge + internal: true + +services: + managementportal-app: + extends: + file: ../management-portal.yml + service: managementportal-app + + managementportal-postgresql: + extends: + file: ../postgresql.yml + service: postgresql + +## smtp server, uncomment if needed +# managementportal-smtp: +# extends: +# file: ../smtp.yml +# service: smtp diff --git a/src/main/docker/mp_local/docker-compose.yml b/src/main/docker/mp_local/docker-compose.yml new file mode 100644 index 000000000..fd58d1670 --- /dev/null +++ b/src/main/docker/mp_local/docker-compose.yml @@ -0,0 +1,17 @@ +# Docker stack to run managementport using a locally built docker image built using the command +# ./gradlew bootWar -Pprod buildDocker + +version: '2' +services: + managementportal-app: + extends: + file: ../management-portal.yml + service: managementportal-app + image: managementportal + environment: + - SPRING_LIQUIBASE_CONTEXTS=dev #includes testing_data, remove for production builds + + managementportal-postgresql: + extends: + file: ../postgresql.yml + service: postgresql diff --git a/src/main/docker/mysql.yml b/src/main/docker/mysql.yml index a28c90abd..5de68abfd 100644 --- a/src/main/docker/mysql.yml +++ b/src/main/docker/mysql.yml @@ -1,6 +1,6 @@ version: '2' services: - managementportal-mysql: + mysql: image: mysql:5.7.13 # volumes: # - ~/volumes/jhipster/ManagementPortal/mysql/:/var/lib/mysql/ @@ -9,5 +9,5 @@ services: - MYSQL_ALLOW_EMPTY_PASSWORD=yes - MYSQL_DATABASE=managementportal ports: - - 3306:3306 + - "3306:3306" command: mysqld --lower_case_table_names=1 --skip-ssl --character_set_server=utf8 diff --git a/src/main/docker/non_mp/docker-compose.yml b/src/main/docker/non_mp/docker-compose.yml new file mode 100644 index 000000000..7cd935a85 --- /dev/null +++ b/src/main/docker/non_mp/docker-compose.yml @@ -0,0 +1,15 @@ +# Docker stack containing all the "required" interacting components to run managementportal +# Intended to use alongside local executables of managementportal (e.g. in an Intellij) for development/debug purposes + +version: '2' +services: + managementportal-postgresql: + extends: + file: ../postgresql.yml + service: managementportal-postgresql + +## smtp server, uncomment if needed +# managementportal-smtp: +# extends: +# file: ../smtp.yml +# service: smtp diff --git a/src/main/docker/postgresql.yml b/src/main/docker/postgresql.yml index e653c678e..4224f4613 100644 --- a/src/main/docker/postgresql.yml +++ b/src/main/docker/postgresql.yml @@ -1,10 +1,10 @@ version: '2' services: - managementportal-postgresql: + postgresql: image: postgres:11-alpine environment: - POSTGRES_USER=radarbase - POSTGRES_PASSWORD=radarbase - POSTGRES_DB=managementportal ports: - - 5432:5432 + - "5432:5432" diff --git a/src/main/docker/docker-compose.yml b/src/main/docker/smtp.yml similarity index 59% rename from src/main/docker/docker-compose.yml rename to src/main/docker/smtp.yml index 6cc17a82e..1de7871ec 100644 --- a/src/main/docker/docker-compose.yml +++ b/src/main/docker/smtp.yml @@ -1,12 +1,4 @@ ---- -version: '2.1' - -networks: - mail: - driver: bridge - internal: true - - +version: '2' services: smtp: image: namshi/smtp:latest @@ -16,4 +8,4 @@ services: - /var/spool/exim restart: always env_file: - - ./etc/smtp.env + - ./etc/smtp.env # generate by filling in ./etc/smpt.env.template diff --git a/src/main/docker/sonar.yml b/src/main/docker/sonar.yml index fcc750b87..fd8585fb2 100644 --- a/src/main/docker/sonar.yml +++ b/src/main/docker/sonar.yml @@ -1,7 +1,7 @@ version: '2' services: - managementportal-sonar: + sonar: image: sonarqube:6.2-alpine ports: - - 9000:9000 - - 9092:9092 + - "9000:9000" + - "9092:9092"