diff --git a/apps/data-platform/project.json b/apps/data-platform/project.json index 3010f8db3f..35b8aa3ae9 100644 --- a/apps/data-platform/project.json +++ b/apps/data-platform/project.json @@ -62,7 +62,7 @@ "executor": "nx:run-commands", "options": { "commands": [ - "docker build -f ./apps/data-platform/Dockerfile . -t $(tools/print-docker-tag.sh data-platform)" + "docker build --build-arg WEB_COMPONENT_VERSION=$(tools/print-wc-version.sh) -f ./apps/data-platform/Dockerfile . -t $(tools/print-docker-tag.sh data-platform)" ] } } diff --git a/apps/datafeeder/project.json b/apps/datafeeder/project.json index 2e37551022..57196ac29b 100644 --- a/apps/datafeeder/project.json +++ b/apps/datafeeder/project.json @@ -106,7 +106,7 @@ "options": { "commands": [ "nx build datafeeder --base-href='/datafeeder/'", - "docker build --build-arg APP_NAME=datafeeder -f ./tools/docker/Dockerfile.apps . -t $(tools/print-docker-tag.sh datafeeder)" + "docker build --build-arg APP_NAME=datafeeder --build-arg WEB_COMPONENT_VERSION=$(tools/print-wc-version.sh) -f ./tools/docker/Dockerfile.apps . -t $(tools/print-docker-tag.sh datafeeder)" ], "parallel": false } diff --git a/apps/datahub/project.json b/apps/datahub/project.json index 48c199e54f..3671ce4b1f 100644 --- a/apps/datahub/project.json +++ b/apps/datahub/project.json @@ -121,7 +121,7 @@ "options": { "commands": [ "nx build datahub --base-href='/datahub/'", - "docker build --build-arg APP_NAME=datahub -f ./tools/docker/Dockerfile.apps . -t $(tools/print-docker-tag.sh datahub)" + "docker build --build-arg APP_NAME=datahub --build-arg WEB_COMPONENT_VERSION=$(tools/print-wc-version.sh) -f ./tools/docker/Dockerfile.apps . -t $(tools/print-docker-tag.sh datahub)" ], "parallel": false } diff --git a/tools/docker/Dockerfile.apps b/tools/docker/Dockerfile.apps index 3e5f991761..2a661c5e8e 100644 --- a/tools/docker/Dockerfile.apps +++ b/tools/docker/Dockerfile.apps @@ -3,6 +3,7 @@ FROM nginx:1.24-alpine +ARG WEB_COMPONENT_VERSION="main" ARG APP_NAME="search" ENV APP_NAME=${APP_NAME} ENV GN4_API_URL "" @@ -14,8 +15,9 @@ ENV CUSTOM_SCRIPTS_DIRECTORY "" COPY dist/apps/${APP_NAME} /usr/share/nginx/html/${APP_NAME} COPY tools/docker/docker-entrypoint.sh / -# copy Web Components HTML embedder as a bonus +# copy Web Components HTML embedder using correct wc script version COPY tools/webcomponent/wc-embedder.html /usr/share/nginx/html/${APP_NAME} +RUN sed -i "s/wc-dist/wc-dist-${WEB_COMPONENT_VERSION}/" /usr/share/nginx/html/${APP_NAME}/wc-embedder.html # copy default NGINX conf & put the app name in it COPY tools/docker/nginx.apps.conf /etc/nginx/conf.d/default.conf diff --git a/tools/print-wc-version.sh b/tools/print-wc-version.sh new file mode 100755 index 0000000000..dd4d375f42 --- /dev/null +++ b/tools/print-wc-version.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Will print the current gitTag or 'main' if none +# This is used for web component versionning +# e.g.: v1.1.0 +# or: main + +gitTag=$(git describe --exact-match --tags 2>/dev/null) + +echo "${gitTag:-main}" \ No newline at end of file