-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try to get a stub for downstream testing of the managementPortal
- Loading branch information
1 parent
25e6b46
commit dfec5c7
Showing
3 changed files
with
273 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
src/integrationTest/resources/docker/docker-compose_downstream.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |