From 821eb62af959aa9e33d3bb654cd516e179124b35 Mon Sep 17 00:00:00 2001 From: Oliver Freeman Date: Wed, 4 May 2022 16:55:15 +0100 Subject: [PATCH 1/2] Initial work to add mdm-explorer to the build. We need some internal fixes to the explorer before we can continue --- mauro-data-mapper/Dockerfile | 15 ++++++++++++ .../build_scripts/build_explorer.sh | 24 +++++++++++++++++++ postgres/Dockerfile | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100755 mauro-data-mapper/build_scripts/build_explorer.sh diff --git a/mauro-data-mapper/Dockerfile b/mauro-data-mapper/Dockerfile index dd40b6a..5c5ffab 100644 --- a/mauro-data-mapper/Dockerfile +++ b/mauro-data-mapper/Dockerfile @@ -10,6 +10,11 @@ ARG MDM_UI_COMMIT=main ARG ADDITIONAL_PLUGINS="" ARG MDM_UI_THEME_NAME="default" ARG MDM_UI_FEATURE_SUBSCRIBED_CATALOGUES="true" + +ARG DEPLOY_MDM_EXPLORER=0 +ARG MDM_EXPLORER_VERSION="1.0.0-SNAPSHOT" +ARG MDM_EXPLORER_BUILD_HOME=/opt/mdm-explorer/dist + # This is needed to ensure the fetch and checkout are always run # If the arg is passed in using a random value then it will invalidate the docker cache and force the following steps to re-run ARG CACHE_BURST=1 @@ -21,6 +26,13 @@ ARG CACHE_BURST=1 # Checkout the desired versions RUN cd "$MDM_APPLICATION_HOME" && git fetch && git checkout "$MDM_APPLICATION_COMMIT" && if [[ `git status` != HEAD\ detached* ]]; then git pull; fi RUN cd "$MDM_UI_HOME" && git fetch && git checkout "$MDM_UI_COMMIT" && if [[ `git status` != HEAD\ detached* ]]; then git pull; fi +RUN mkdir -p $MDM_EXPLORER_BUILD_HOME + +# Copy in the building scripts +COPY build_scripts /usr/local/bin/ + +# Make sure all scripts are executable +RUN chmod a+x /usr/local/bin/* # Copy in build.yml COPY config/build.yml $MDM_APPLICATION_HOME/grails-app/conf/build.yml @@ -31,6 +43,7 @@ COPY mdm-ui $MDM_UI_HOME/ # Build the front and back ends # The front end build will try to use precompiled sources or it will build locally from the given commit/tagU RUN build_frontend.sh +RUN build_explorer.sh # The only way to include plugins is to build the API manually, however this actually takes very little time as we already have all the # dependencies downloaded @@ -48,7 +61,9 @@ FROM maurodatamapper/tomcat:$TOMCAT_IMAGE_VERSION LABEL maintainer="Oliver Freeman " ARG MDM_BUILD_HOME=/opt/mdm +ARG MDM_EXPLORER_BUILD_HOME=/opt/mdm-explorer/dist ENV CATALINA_OPTS="-Xmx8g -Xms512m -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+UseCompressedOops" COPY --from=mdm-build ${MDM_BUILD_HOME} ${CATALINA_HOME}/webapps/ROOT +COPY --from=mdm-build ${MDM_EXPLORER_BUILD_HOME} ${CATALINA_HOME}/webapps/explorer diff --git a/mauro-data-mapper/build_scripts/build_explorer.sh b/mauro-data-mapper/build_scripts/build_explorer.sh new file mode 100755 index 0000000..46e2183 --- /dev/null +++ b/mauro-data-mapper/build_scripts/build_explorer.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +precompiledBuild(){ + echo 'Using pre-compiled source' + + if [[ $MDM_EXPLORER_VERSION == *SNAPSHOT ]] + then + MDM_EXPLORER_LIBRARY='artifacts-snapshots' + else + MDM_EXPLORER_LIBRARY='artifacts' + fi + + MDM_EXPLORER_URL="http://jenkins.cs.ox.ac.uk/artifactory/${MDM_EXPLORER_LIBRARY}/mauroDataMapper/mdm-explorer/mdm-explorer-${MDM_EXPLORER_VERSION}.tgz" + + echo "Downloading precompiled sources ${MDM_EXPLORER_URL}" + + cd /opt || exit + curl -LO "$MDM_EXPLORER_URL" + tar xzf "mdm-explorer-${MDM_EXPLORER_VERSION}.tgz" + mkdir "$MDM_EXPLORER_BUILD_HOME" + cp -r "mdm-explorer-${MDM_EXPLORER_VERSION}"/* "$MDM_EXPLORER_BUILD_HOME" +} + +precompiledBuild \ No newline at end of file diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 51cce9f..cd370d7 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -1,4 +1,4 @@ -FROM postgres:12.0-alpine +FROM postgres:12.10-alpine COPY fixtures /docker-entrypoint-initdb.d ENV POSTGRES_PASSWORD=postgresisawesome \ From aa4e336132016b11c5e7c317cba4e3fe808bcf94 Mon Sep 17 00:00:00 2001 From: Oliver Freeman Date: Fri, 17 Jun 2022 17:13:02 +0100 Subject: [PATCH 2/2] Use sed to update the apiendpoint for compiled builds This does require the user to set the MDM_EXPLORER_API_ENDPOINT to the correct FQDN URL for the MDM API --- docker-compose.yml | 1 + mauro-data-mapper/Dockerfile | 1 + mauro-data-mapper/build_scripts/build_explorer.sh | 2 ++ 3 files changed, 4 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 1a484d7..0025d8e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,6 +19,7 @@ services: ADDITIONAL_PLUGINS: "" MDM_UI_THEME_NAME: "default" CACHE_BURST: "${CACHE_BURST}" + MDM_EXPLORER_API_ENDPOINT: "http://localhost:${MDM_PORT}/api" environment: PGPASSWORD: postgresisawesome runtime.config.path: /usr/local/tomcat/conf/runtime.yml diff --git a/mauro-data-mapper/Dockerfile b/mauro-data-mapper/Dockerfile index 5c5ffab..f340704 100644 --- a/mauro-data-mapper/Dockerfile +++ b/mauro-data-mapper/Dockerfile @@ -14,6 +14,7 @@ ARG MDM_UI_FEATURE_SUBSCRIBED_CATALOGUES="true" ARG DEPLOY_MDM_EXPLORER=0 ARG MDM_EXPLORER_VERSION="1.0.0-SNAPSHOT" ARG MDM_EXPLORER_BUILD_HOME=/opt/mdm-explorer/dist +ARG MDM_EXPLORER_API_ENDPOINT="http://localhost:${MDM_PORT}/api" # This is needed to ensure the fetch and checkout are always run # If the arg is passed in using a random value then it will invalidate the docker cache and force the following steps to re-run diff --git a/mauro-data-mapper/build_scripts/build_explorer.sh b/mauro-data-mapper/build_scripts/build_explorer.sh index 46e2183..5a49322 100755 --- a/mauro-data-mapper/build_scripts/build_explorer.sh +++ b/mauro-data-mapper/build_scripts/build_explorer.sh @@ -19,6 +19,8 @@ precompiledBuild(){ tar xzf "mdm-explorer-${MDM_EXPLORER_VERSION}.tgz" mkdir "$MDM_EXPLORER_BUILD_HOME" cp -r "mdm-explorer-${MDM_EXPLORER_VERSION}"/* "$MDM_EXPLORER_BUILD_HOME" + + find "$MDM_EXPLORER_BUILD_HOME" -name main.*.js -exec sed -e "s|apiEndpoint:\"api\",|apiEndpoint:\"${MDM_EXPLORER_API_ENDPOINT}\",|g" -i {} \; } precompiledBuild \ No newline at end of file