Skip to content

Commit

Permalink
Try to get a stub for downstream testing of the managementPortal
Browse files Browse the repository at this point in the history
  • Loading branch information
Bdegraaf1234 committed Nov 9, 2023
1 parent 25e6b46 commit dfec5c7
Show file tree
Hide file tree
Showing 3 changed files with 273 additions and 10 deletions.
139 changes: 139 additions & 0 deletions .github/workflows/downstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Continuous integration, including test and integration test
name: CI

# Run in master and dev branches and in all pull requests to those branches
on:
push:
branches: [ master, dev ]
pull_request:
branches: [ master, dev ]

env:
DOCKER_IMAGE: radarbase/radar-appserver

jobs:
# Build and test the code
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin

- uses: gradle/gradle-build-action@v2

# Compile the code
- name: Compile code
run: ./gradlew assemble

- name: Setup docker services
run: |
sudo mkdir -p /usr/local/var/lib/radar/appserver/logs/
sudo chown -R $(whoami) /usr/local/var/lib/radar/appserver/logs
docker-compose -f src/integrationTest/resources/docker/docker-compose_downstream.yml up -d postgres managementportal managementportal-postgresql
# Wait for services to start up.
sleep 50
- name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.GPG_SECRET_KEY }}") | gpg --batch --import
gpg --list-secret-keys --keyid-format LONG
- name: Decrypt google application credentials
run: |
gpg --pinentry-mode loopback --local-user "Yatharth Ranjan" --batch --yes --passphrase "${{ secrets.GPG_SECRET_KEY_PASSPHRASE }}" --output src/integrationTest/resources/google-credentials.json --decrypt src/integrationTest/resources/google-credentials.enc.gpg
# Gradle check
- name: Check
run: GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/src/integrationTest/resources/google-credentials.json ./gradlew check

- name: Upload build artifacts
if: always()
uses: actions/upload-artifact@v3
with:
path: build/reports
if-no-files-found: ignore
retention-days: 5

# Check that the docker image builds correctly
docker:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Add Docker labels and tags
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_IMAGE }}

# Setup docker build environment
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
id: cache-buildx
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile', '**/*.gradle.kts', 'gradle.properties', 'src/main/**') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Cache parameters
id: cache-parameters
run: |
if [ "${{ steps.cache-buildx.outputs.cache-hit }}" = "true" ]; then
echo "::set-output name=cache-to::"
else
echo "::set-output name=cache-to::type=local,dest=/tmp/.buildx-cache-new,mode=max"
fi
- name: Build docker
uses: docker/build-push-action@v3
with:
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: ${{ steps.cache-parameters.outputs.cache-to }}
load: true
tags: ${{ steps.docker_meta.outputs.tags }}
# Use runtime labels from docker_meta as well as fixed labels
labels: |
${{ steps.docker_meta.outputs.labels }}
maintainer=Yatharth Ranjan <yatharth.ranjan@kcl.ac.uk>, Pauline Conde <pauline.conde@kcl.ac.uk>
org.opencontainers.image.authors=Yatharth Ranjan <yatharth.ranjan@kcl.ac.uk>, Pauline Conde <pauline.conde@kcl.ac.uk>
org.opencontainers.image.vendor=RADAR-base
org.opencontainers.image.licenses=Apache-2.0
- name: Inspect docker image
run: docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move docker build cache
if: steps.cache-buildx.outputs.cache-hit != 'true'
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache


38 changes: 28 additions & 10 deletions src/integrationTest/resources/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ networks:
admin:
driver: bridge
internal: true
mp:
driver: bridge
internal: true

services:
postgres:
Expand Down Expand Up @@ -64,18 +67,33 @@ services:
# Management Portal #
#---------------------------------------------------------------------------#
managementportal:
image: radarbase/management-portal:2.0.0
# image: radarbase/management-portal:2.1.0
image: managementportal:latest
networks:
- mp
ports:
- "8081:8081"
depends_on:
- managementportal-postgresql
environment:
SPRING_PROFILES_ACTIVE: dev
SERVER_PORT: 8081
MANAGEMENTPORTAL_FRONTEND_CLIENT_SECRET: ""
MANAGEMENTPORTAL_COMMON_BASE_URL: http://localhost:8081/managementportal
MANAGEMENTPORTAL_COMMON_MANAGEMENT_PORTAL_BASE_URL: http://localhost:8081/managementportal
MANAGEMENTPORTAL_OAUTH_CLIENTS_FILE: /mp-includes/config/oauth_client_details.csv
MANAGEMENTPORTAL_CATALOGUE_SERVER_ENABLE_AUTO_IMPORT: 'false'
SERVER_SERVLET_CONTEXT_PATH: /managementportal
JAVA_OPTS: -Xmx256m # maximum heap size for the JVM running ManagementPortal, increase this as necessary
- SPRING_PROFILES_ACTIVE=prod,e2e-prod-test
- SERVER_PORT=8081
- 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=
- MANAGEMENTPORTAL_OAUTH_CLIENTS_FILE=/mp-includes/config/oauth_client_details.csv
- 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
volumes:
- ./etc/:/mp-includes/

managementportal-postgresql:
image: postgres:11-alpine
networks:
- mp
environment:
- POSTGRES_USER=radarbase
- POSTGRES_PASSWORD=radarbase
- POSTGRES_DB=managementportal
106 changes: 106 additions & 0 deletions src/integrationTest/resources/docker/docker-compose_downstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
version: '2.1'

networks:
db:
driver: bridge
internal: true
admin:
driver: bridge
internal: true
mp:
driver: bridge
internal: true
ext:
driver: bridge
internal: false

services:
postgres:
image: postgres
restart: always
networks:
- db
- default
- ext
environment:
POSTGRES_DB: radar
POSTGRES_PASSWORD: radar
ports:
- "5432:5432"

appserver:
build: ../../../..
restart: always
networks:
- db
- default
- admin
ports:
- "8080:8080"
depends_on:
- postgres
- spring-boot-admin
volumes:
- ../radar-is.yml:/resources/radar-is.yml
- ../../../../logs/:/var/log/radar/appserver/
environment:
JDK_JAVA_OPTIONS: -Xmx4G -Djava.security.egd=file:/dev/./urandom
FCMSERVER_SENDERID: "1043784930865"
FCMSERVER_SERVERKEY: "AAAA8wZuFjE:APA91bGpJQ3Sft0mZAaVMjDJGNLjFsdDLTo-37ZN69r4lKlHiRN78t4bCfkNKcXG5c9cJg-eGtWB7FqceQUDVtf7B1Zvw_2ycynqwKe2YqXFeyaq83Gf0R3AS1EKSWFS60GCr8eUEliz"
RADAR_ADMIN_USER: "radar"
RADAR_ADMIN_PASSWORD: "radar"
SPRING_APPLICATION_JSON: '{"spring":{"boot":{"admin":{"client":{"url":"http://spring-boot-admin:1111","username":"radar","password":"appserver"}}}}}'
RADAR_IS_CONFIG_LOCATION: "/resources/radar-is.yml"
SPRING_BOOT_ADMIN_CLIENT_INSTANCE_NAME: radar-appserver

spring-boot-admin:
image: slydeveloper/spring-boot-admin:latest
restart: always
networks:
- admin
- default
ports:
- "8888:1111"
environment:
SPRING_BOOT_ADMIN_USER_NAME: radar
SPRING_BOOT_ADMIN_USER_PASSWORD: appserver
SPRING_BOOT_ADMIN_TITLE: RADAR-appserver
SPRING_APPLICATION_JSON: '{"spring":{"boot":{"admin":{"username":"radar","password":"appserver","title":"RADAR-appserver"}}}}'

#---------------------------------------------------------------------------#
# Management Portal #
#---------------------------------------------------------------------------#
managementportal:
image: radarbase/management-portal:dev
depends_on:
- managementportal-postgresql
networks:
- mp
- ext
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=
- SERVER_PORT=8081
- MANAGEMENTPORTAL_COMMON_BASE_URL=http://localhost:8081/managementportal
- MANAGEMENTPORTAL_COMMON_MANAGEMENT_PORTAL_BASE_URL=http://localhost:8081/managementportal
- MANAGEMENTPORTAL_OAUTH_CLIENTS_FILE=/mp-includes/config/oauth_client_details.csv
- MANAGEMENTPORTAL_CATALOGUE_SERVER_ENABLE_AUTO_IMPORT=false
- 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:
- "8081:8081"
volumes:
- ./etc:/mp-includes

managementportal-postgresql:
image: postgres:11-alpine
environment:
- POSTGRES_USER=radarbase
- POSTGRES_PASSWORD=radarbase
- POSTGRES_DB=managementportal
networks:
- mp

0 comments on commit dfec5c7

Please sign in to comment.