From a17bfb8cbef860f09197cda0d7413f490634c1a9 Mon Sep 17 00:00:00 2001 From: Tristan Huet Date: Tue, 25 Nov 2025 19:09:33 +0100 Subject: [PATCH 1/5] feat: add build number in Technical Information dialog --- src/components/TechnicalInfoContent/TechnicalInfoContent.js | 1 + src/config/HelpMenuConfiguration.json | 1 + src/config/HelpMenuConfiguration.vanilla.json | 1 + 3 files changed, 3 insertions(+) diff --git a/src/components/TechnicalInfoContent/TechnicalInfoContent.js b/src/components/TechnicalInfoContent/TechnicalInfoContent.js index 133e7d746..ea8806f0c 100644 --- a/src/components/TechnicalInfoContent/TechnicalInfoContent.js +++ b/src/components/TechnicalInfoContent/TechnicalInfoContent.js @@ -21,6 +21,7 @@ export const TechnicalInfoContent = () => { id: 'webappVersion', label: t('genericcomponent.dialog.technicalInfo.webAppVersion', 'Webapp version:'), content: ConfigService.getParameterValue('APP_VERSION'), + subcontent: ConfigService.getParameterValue('BUILD_NUMBER'), }, { id: 'apiVersion', diff --git a/src/config/HelpMenuConfiguration.json b/src/config/HelpMenuConfiguration.json index 2badd1a70..65183cd9a 100644 --- a/src/config/HelpMenuConfiguration.json +++ b/src/config/HelpMenuConfiguration.json @@ -1,5 +1,6 @@ { "APP_VERSION": null, + "BUILD_NUMBER": null, "ORGANIZATION_URL": "https://cosmotech.com", "DOCUMENTATION_URL": "https://portal.cosmotech.com/resources/platform-resources/web-app-user-guide", "SUPPORT_URL": "https://support.cosmotech.com" diff --git a/src/config/HelpMenuConfiguration.vanilla.json b/src/config/HelpMenuConfiguration.vanilla.json index dd5ba57c9..a1e88b4a3 100644 --- a/src/config/HelpMenuConfiguration.vanilla.json +++ b/src/config/HelpMenuConfiguration.vanilla.json @@ -1,5 +1,6 @@ { "APP_VERSION": null, + "BUILD_NUMBER": null, "ORGANIZATION_URL": "https://cosmotech.com", "DOCUMENTATION_URL": "", "SUPPORT_URL": "https://support.cosmotech.com" From 769363dcbb5e69649d07750e379211749973f2f7 Mon Sep 17 00:00:00 2001 From: Tristan Huet Date: Tue, 25 Nov 2025 19:55:25 +0100 Subject: [PATCH 2/5] build: add build number in app version at build time --- package.json | 4 ++-- webapp_server/README.md | 17 ++++++++++++----- webapp_server/webapp-server.Dockerfile | 5 ++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index d39270b0c..ffb3bffb5 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,8 @@ "zod": "^4.1.9" }, "scripts": { - "start": "cross-env DISABLE_ESLINT_PLUGIN=true REACT_APP_APP_VERSION=$npm_package_version HOST=localhost react-app-rewired start", - "build": "cross-env DISABLE_ESLINT_PLUGIN=true REACT_APP_APP_VERSION=$npm_package_version react-app-rewired build", + "start": "cross-env DISABLE_ESLINT_PLUGIN=true REACT_APP_APP_VERSION=$npm_package_version REACT_APP_BUILD_NUMBER=$REACT_APP_BUILD_NUMBER HOST=localhost react-app-rewired start", + "build": "cross-env DISABLE_ESLINT_PLUGIN=true REACT_APP_APP_VERSION=$npm_package_version REACT_APP_BUILD_NUMBER=$REACT_APP_BUILD_NUMBER react-app-rewired build", "test": "jest --coverage=false", "eject": "react-app-rewired eject", "cypress": "node_modules/.bin/cypress open", diff --git a/webapp_server/README.md b/webapp_server/README.md index 1823e3be7..f6c429e30 100644 --- a/webapp_server/README.md +++ b/webapp_server/README.md @@ -33,9 +33,13 @@ container: # Change directory to the root of the repository cd azure-sample-webapp +# Optional step to add build number in app version +REACT_APP_BUILD_NUMBER=$(git rev-parse --short HEAD) + # Build the docker image of the webapp server DOCKER_BUILDKIT=1 docker build \ --build-arg BUILDKIT_INLINE_CACHE=1 \ + --build-arg REACT_APP_BUILD_NUMBER=$REACT_APP_BUILD_NUMBER \ -t webapp_server \ -f webapp_server/webapp-server.Dockerfile . @@ -57,12 +61,16 @@ container: # Change directory to the root of the repository cd azure-sample-webapp +# Optional step to add build number in app version +REACT_APP_BUILD_NUMBER=$(git rev-parse --short HEAD) + # Build the docker image of the webapp server DOCKER_BUILDKIT=1 docker build \ ---build-arg BUILDKIT_INLINE_CACHE=1 \ ---target server-universal \ --t webapp_server \ --f webapp_server/webapp-server.Dockerfile . + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --build-arg REACT_APP_BUILD_NUMBER=$REACT_APP_BUILD_NUMBER \ + --target server-universal \ + -t webapp_server \ + -f webapp_server/webapp-server.Dockerfile . # Run the container with: docker run --rm -it -p 3000:3000 \ @@ -95,7 +103,6 @@ DOCKER_BUILDKIT=1 docker build \ --build-arg BUILDKIT_INLINE_CACHE=1 \ -t webapp_functions \ -f ../webapp_server/webapp-functions.Dockerfile . - ``` Then, create a `.env` file to store the environment variables required by the functions, and adapt the values below: diff --git a/webapp_server/webapp-server.Dockerfile b/webapp_server/webapp-server.Dockerfile index ca697a2d2..58cac72d2 100644 --- a/webapp_server/webapp-server.Dockerfile +++ b/webapp_server/webapp-server.Dockerfile @@ -16,6 +16,8 @@ RUN --mount=type=bind,source=package.json,target=package.json \ FROM install_build_dependencies AS build-universal COPY . . +ARG REACT_APP_BUILD_NUMBER +ENV REACT_APP_BUILD_NUMBER=${REACT_APP_BUILD_NUMBER} RUN BUILD_TYPE="universal" yarn build # ==== Build - "specific" server mode ==== @@ -24,6 +26,8 @@ FROM install_build_dependencies AS build-specific COPY . . ARG PUBLIC_URL ENV PUBLIC_URL=${PUBLIC_URL} +ARG REACT_APP_BUILD_NUMBER +ENV REACT_APP_BUILD_NUMBER=${REACT_APP_BUILD_NUMBER} RUN PUBLIC_URL="$PUBLIC_URL" yarn build @@ -54,7 +58,6 @@ FROM node:24-slim AS server-specific LABEL com.cosmotech.business-webapp.buildType="specific" WORKDIR /webapp ENV NODE_ENV=production -ENV NODE_ENV production RUN npm install -g serve@^14.2.5 COPY --from=build-specific /webapp/build ./build From 21043bacfc52c252e7d6d1134538d03008e5df20 Mon Sep 17 00:00:00 2001 From: Tristan Huet Date: Tue, 25 Nov 2025 19:55:49 +0100 Subject: [PATCH 3/5] ci: add build number in ASWA GitHub workflow --- .../azure-static-web-apps-lively-ground-0cb943403.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/azure-static-web-apps-lively-ground-0cb943403.yml b/.github/workflows/azure-static-web-apps-lively-ground-0cb943403.yml index bfffd047b..0059941b0 100644 --- a/.github/workflows/azure-static-web-apps-lively-ground-0cb943403.yml +++ b/.github/workflows/azure-static-web-apps-lively-ground-0cb943403.yml @@ -9,6 +9,9 @@ on: branches: - main +env: + REACT_APP_BUILD_NUMBER: ${{ github.event.pull_request.head.sha || github.sha }} + jobs: build_and_deploy_job: if: ${{ ! startsWith(github.head_ref, 'dependabot/') && ( github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') ) }} From 14e78d9f485472b49c0f783aac838dced4e5c951 Mon Sep 17 00:00:00 2001 From: Tristan Huet Date: Tue, 25 Nov 2025 20:01:45 +0100 Subject: [PATCH 4/5] ci: add build number in docker build GitHub workflow --- .github/workflows/build-push-webapp-server-docker-images.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-push-webapp-server-docker-images.yml b/.github/workflows/build-push-webapp-server-docker-images.yml index 9f672b0eb..b4a55f153 100644 --- a/.github/workflows/build-push-webapp-server-docker-images.yml +++ b/.github/workflows/build-push-webapp-server-docker-images.yml @@ -24,6 +24,7 @@ env: # Change the Container Registry information below if necessary REGISTRY: ghcr.io REPOSITORY_NAME: ${{ github.repository }} + REACT_APP_BUILD_NUMBER: ${{ github.sha }} # PUBLIC_URL is only required when building the server in instance-specific mode #PUBLIC_URL: /cosmotech-webapp/brewery @@ -79,7 +80,8 @@ jobs: # Target stage can be either server-universal or server-specific (default) target: server-universal # PUBLIC_URL is only required when building the server in instance-specific mode - #build-args: | + build-args: | + "REACT_APP_BUILD_NUMBER=${{ env.REACT_APP_BUILD_NUMBER }}" # "PUBLIC_URL=${{ env.PUBLIC_URL }}" - name: "webapp-functions: extract Docker metadata (tags, labels)" From f0d52af1afadb5323c2771c9d26dd95ee71de181 Mon Sep 17 00:00:00 2001 From: Tristan Huet Date: Wed, 26 Nov 2025 11:38:51 +0100 Subject: [PATCH 5/5] fix: [FIXUP] --- src/components/TechnicalInfoContent/TechnicalInfoContent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TechnicalInfoContent/TechnicalInfoContent.js b/src/components/TechnicalInfoContent/TechnicalInfoContent.js index ea8806f0c..d8885a090 100644 --- a/src/components/TechnicalInfoContent/TechnicalInfoContent.js +++ b/src/components/TechnicalInfoContent/TechnicalInfoContent.js @@ -21,7 +21,7 @@ export const TechnicalInfoContent = () => { id: 'webappVersion', label: t('genericcomponent.dialog.technicalInfo.webAppVersion', 'Webapp version:'), content: ConfigService.getParameterValue('APP_VERSION'), - subcontent: ConfigService.getParameterValue('BUILD_NUMBER'), + subcontent: ConfigService.getParameterValue('BUILD_NUMBER')?.substring(0, 7), }, { id: 'apiVersion',