diff --git a/frontend/.env.sample b/frontend/.env.sample index 1d7537e86..1e8bf7622 100644 --- a/frontend/.env.sample +++ b/frontend/.env.sample @@ -22,5 +22,5 @@ MINIO_ACCESS_KEY = '' MINIO_SECRET_KEY = '' # APP and TRACKER VERSIONS -VERSION = 1.14.10 +VERSION = 1.14.11 TRACKER_VERSION = '9.0.0' diff --git a/frontend/build.sh b/frontend/build.sh index e95aa35ff..cea9019bd 100644 --- a/frontend/build.sh +++ b/frontend/build.sh @@ -8,6 +8,11 @@ # Example # Usage: IMAGE_TAG=latest DOCKER_REPO=myDockerHubID bash build.sh +ARCH=${ARCH:-amd64} + +GIT_ROOT=$(git rev-parse --show-toplevel) +source $GIT_ROOT/scripts/lib/_docker.sh + git_sha=$(git rev-parse --short HEAD) image_tag=${IMAGE_TAG:-$git_sha} check_prereq() { @@ -17,34 +22,42 @@ check_prereq() { } } +# Sourcing init scripts +for file in ./build_init_*; do + if [ -f "$file" ]; then + echo "Sourcing $file" + source "$file" + fi +done + chart=frontend [[ $1 == ee ]] && ee=true [[ $PATCH -eq 1 ]] && { - __app_version="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/${chart} | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}' | cut -d 'v' -f2)" - sed -i "s/^VERSION = .*/VERSION = $__app_version/g" .env.sample - image_tag="v${__app_version}" - [[ $ee == "true" ]] && { - image_tag="${image_tag}-ee" - } + __app_version="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/${chart} | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}' | cut -d 'v' -f2)" + sed -i "s/^VERSION = .*/VERSION = $__app_version/g" .env.sample + image_tag="v${__app_version}" + [[ $ee == "true" ]] && { + image_tag="${image_tag}-ee" + } } update_helm_release() { - [[ $ee == true ]] && return - HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" - # Update the chart version - sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml - # Update image tags - sed -i "s#ppVersion.*#ppVersion: \"v${__app_version}\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml - # Commit the changes - git add .env.sample - git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml - git commit -m "chore(helm): Updating $chart image release" + [[ $ee == true ]] && return + HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" + # Update the chart version + sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Update image tags + sed -i "s#ppVersion.*#ppVersion: \"v${__app_version}\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + # Commit the changes + git add .env.sample + git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml + git commit -m "chore(helm): Updating $chart image release" } # https://github.com/docker/cli/issues/1134#issuecomment-613516912 export DOCKER_BUILDKIT=1 -function build(){ +function build() { # Run docker as the same user, else we'll run in to permission issues. - docker build -t ${DOCKER_REPO:-'local'}/frontend:${image_tag} --platform linux/amd64 --build-arg GIT_SHA=$git_sha . + docker build -t ${DOCKER_REPO:-'local'}/frontend:${image_tag} --platform linux/${ARCH} --build-arg GIT_SHA=$git_sha . [[ $PUSH_IMAGE -eq 1 ]] && { docker push ${DOCKER_REPO:-'local'}/frontend:${image_tag} } @@ -56,4 +69,4 @@ function build(){ check_prereq build $1 -[[ $PATCH -eq 1 ]] && update_helm_release +[[ $PATCH -eq 1 ]] && update_helm_release || true diff --git a/scripts/helmcharts/openreplay/charts/frontend/Chart.yaml b/scripts/helmcharts/openreplay/charts/frontend/Chart.yaml index cf73df7e9..b7d59de74 100644 --- a/scripts/helmcharts/openreplay/charts/frontend/Chart.yaml +++ b/scripts/helmcharts/openreplay/charts/frontend/Chart.yaml @@ -15,10 +15,10 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (frontends://semver.org/) -version: 0.1.20 +version: 0.1.21 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -AppVersion: "v1.14.10" +AppVersion: "v1.14.11" diff --git a/scripts/lib/_docker.sh b/scripts/lib/_docker.sh new file mode 100644 index 000000000..345cc4e1b --- /dev/null +++ b/scripts/lib/_docker.sh @@ -0,0 +1,14 @@ +#!/bin/bash +docker() { + local docker_cmd=${DOCKER_RUNTIME:-"docker"} + [[ $docker_cmd == "docker" ]] && docker_cmd=$(which docker) + if [[ "$1" == "build" ]]; then + shift + # Reconstruct command with DOCKER_ARGS before the '.' + $docker_cmd build ${DOCKER_BUILD_ARGS} "$@" + else + $docker_cmd "$@" + fi +} + +export -f docker