openreplay/frontend/build.sh
Rajesh Rajendran 0cd7f68452 Create PR environment on PRs (#1671)
* refactor(helm): minio size limit to 5Gi
* feat(actions): pr-env action
* Adding pr-env configs
* Update PR env creation with latest requirements (#1658)
* fixesss
* fix pr env variable
* enble debugging
* Automatically take PR number from branch
* pr-env: taking open pr number only (#1669)
* pr-env: taking open pr number only
* enable ee cluster installation
* pr-env adding resource constraints
* pr-env: build and deploy applications

Signed-off-by: rjshrjndrn <rjshrjndrn@gmail.com>
2023-11-20 16:15:12 +01:00

59 lines
2 KiB
Bash

#!/bin/bash
# Script to build api module
# flags to accept:
# ee: build for enterprise edition.
# Default will be OSS build.
# Example
# Usage: IMAGE_TAG=latest DOCKER_REPO=myDockerHubID bash build.sh
git_sha=$(git rev-parse --short HEAD)
image_tag=${IMAGE_TAG:-$git_sha}
check_prereq() {
which docker || {
echo "Docker not installed, please install docker."
exit 100
}
}
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"
}
}
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"
}
# https://github.com/docker/cli/issues/1134#issuecomment-613516912
export DOCKER_BUILDKIT=1
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 .
[[ $PUSH_IMAGE -eq 1 ]] && {
docker push ${DOCKER_REPO:-'local'}/frontend:${image_tag}
}
[[ $SIGN_IMAGE -eq 1 ]] && {
cosign sign --key $SIGN_KEY ${DOCKER_REPO:-'local'}/frontend:${image_tag}
}
echo "frontend build completed"
}
check_prereq
build $1
[[ $PATCH -eq 1 ]] && update_helm_release || true