Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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') ) }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/build-push-webapp-server-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')?.substring(0, 7),
},
{
id: 'apiVersion',
Expand Down
1 change: 1 addition & 0 deletions src/config/HelpMenuConfiguration.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/config/HelpMenuConfiguration.vanilla.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"APP_VERSION": null,
"BUILD_NUMBER": null,
"ORGANIZATION_URL": "https://cosmotech.com",
"DOCUMENTATION_URL": "",
"SUPPORT_URL": "https://support.cosmotech.com"
Expand Down
17 changes: 12 additions & 5 deletions webapp_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 .

Expand All @@ -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 \
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion webapp_server/webapp-server.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ====
Expand All @@ -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


Expand Down Expand Up @@ -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
Expand Down
Loading