chore(build): Custom docker build env

This commit is contained in:
rjshrjndrn 2024-03-12 16:13:59 +01:00
parent 8c9ed6a941
commit 068f29fc35
9 changed files with 125 additions and 118 deletions

View file

@ -15,6 +15,8 @@ exit_err() {
fi fi
} }
source ../scripts/lib/_docker.sh
environment=$1 environment=$1
git_sha=$(git rev-parse --short HEAD) git_sha=$(git rev-parse --short HEAD)
image_tag=${IMAGE_TAG:-git_sha} image_tag=${IMAGE_TAG:-git_sha}

View file

@ -10,6 +10,7 @@
git_sha=$(git rev-parse --short HEAD) git_sha=$(git rev-parse --short HEAD)
image_tag=${IMAGE_TAG:-git_sha} image_tag=${IMAGE_TAG:-git_sha}
envarg="default-foss" envarg="default-foss"
source ../scripts/lib/_docker.sh
check_prereq() { check_prereq() {
which docker || { which docker || {
echo "Docker not installed, please install docker." echo "Docker not installed, please install docker."
@ -17,27 +18,26 @@ check_prereq() {
} }
} }
[[ $1 == ee ]] && ee=true [[ $1 == ee ]] && ee=true
[[ $PATCH -eq 1 ]] && { [[ $PATCH -eq 1 ]] && {
image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')"
[[ $ee == "true" ]] && { [[ $ee == "true" ]] && {
image_tag="${image_tag}-ee" image_tag="${image_tag}-ee"
} }
} }
update_helm_release() { update_helm_release() {
chart=$1 chart=$1
HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')"
# Update the chart version # Update the chart version
sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
# Update image tags # Update image tags
sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
# Commit the changes # Commit the changes
git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
git commit -m "chore(helm): Updating $chart image release" git commit -m "chore(helm): Updating $chart image release"
} }
function build_alerts(){ function build_alerts() {
destination="_alerts" destination="_alerts"
[[ $1 == "ee" ]] && { [[ $1 == "ee" ]] && {
destination="_alerts_ee" destination="_alerts_ee"
@ -69,5 +69,5 @@ function build_alerts(){
check_prereq check_prereq
build_alerts $1 build_alerts $1
if [[ $PATCH -eq 1 ]]; then if [[ $PATCH -eq 1 ]]; then
update_helm_release alerts update_helm_release alerts
fi fi

View file

@ -9,6 +9,7 @@
git_sha1=${IMAGE_TAG:-$(git rev-parse HEAD)} git_sha1=${IMAGE_TAG:-$(git rev-parse HEAD)}
envarg="default-foss" envarg="default-foss"
source ../scripts/lib/_docker.sh
check_prereq() { check_prereq() {
which docker || { which docker || {
echo "Docker not installed, please install docker." echo "Docker not installed, please install docker."
@ -17,7 +18,7 @@ check_prereq() {
[[ exit -eq 1 ]] && exit 1 [[ exit -eq 1 ]] && exit 1
} }
function build_crons(){ function build_crons() {
destination="_crons_ee" destination="_crons_ee"
cp -R ../api ../${destination} cp -R ../api ../${destination}
cd ../${destination} cd ../${destination}
@ -46,7 +47,6 @@ check_prereq
[[ $1 == "ee" ]] && { [[ $1 == "ee" ]] && {
build_crons $1 build_crons $1
} || { } || {
echo -e "Crons is only for ee. Rerun the script using \n bash $0 ee" echo -e "Crons is only for ee. Rerun the script using \n bash $0 ee"
exit 100 exit 100
} }

View file

@ -9,19 +9,20 @@
# Helper function # Helper function
exit_err() { exit_err() {
err_code=$1 err_code=$1
if [[ $err_code != 0 ]]; then if [[ $err_code != 0 ]]; then
exit "$err_code" exit "$err_code"
fi fi
} }
source ../scripts/lib/_docker.sh
app="assist-stats" # Set the app variable to "chalice" app="assist-stats" # Set the app variable to "chalice"
environment=$1 environment=$1
git_sha=$(git rev-parse --short HEAD) git_sha=$(git rev-parse --short HEAD)
image_tag=${IMAGE_TAG:-git_sha} image_tag=${IMAGE_TAG:-git_sha}
envarg="default-foss" envarg="default-foss"
chart="$app" # Use the app variable here chart="$app" # Use the app variable here
check_prereq() { check_prereq() {
which docker || { which docker || {
echo "Docker not installed, please install docker." echo "Docker not installed, please install docker."
@ -32,31 +33,31 @@ check_prereq() {
[[ $1 == ee ]] && ee=true [[ $1 == ee ]] && ee=true
[[ $PATCH -eq 1 ]] && { [[ $PATCH -eq 1 ]] && {
image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')"
[[ $ee == "true" ]] && { [[ $ee == "true" ]] && {
image_tag="${image_tag}-ee" image_tag="${image_tag}-ee"
} }
} }
update_helm_release() { update_helm_release() {
[[ $ee == "true" ]] && return [[ $ee == "true" ]] && return
HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')"
# Update the chart version # Update the chart version
sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
# Update image tags # Update image tags
sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
# Commit the changes # Commit the changes
git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
git commit -m "chore(helm): Updating $chart image release" git commit -m "chore(helm): Updating $chart image release"
} }
function build_api(){ function build_api() {
destination="_assist_stats" destination="_assist_stats"
[[ $1 == "ee" ]] && { [[ $1 == "ee" ]] && {
destination="_assist_stats_ee" destination="_assist_stats_ee"
} }
[[ -d ../${destination} ]] && { [[ -d ../${destination} ]] && {
echo "Removing previous build cache" echo "Removing previous build cache"
rm -rf ../${destination} rm -rf ../${destination}
} }
cp -R ../assist-stats ../${destination} cp -R ../assist-stats ../${destination}
cd ../${destination} || exit_err 100 cd ../${destination} || exit_err 100
@ -86,5 +87,5 @@ check_prereq
build_api $environment build_api $environment
echo buil_complete echo buil_complete
if [[ $PATCH -eq 1 ]]; then if [[ $PATCH -eq 1 ]]; then
update_helm_release update_helm_release
fi fi

View file

@ -14,34 +14,35 @@ check_prereq() {
exit 1 exit 1
} }
} }
source ../scripts/lib/_docker.sh
[[ $1 == ee ]] && ee=true [[ $1 == ee ]] && ee=true
[[ $PATCH -eq 1 ]] && { [[ $PATCH -eq 1 ]] && {
image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')"
[[ $ee == "true" ]] && { [[ $ee == "true" ]] && {
image_tag="${image_tag}-ee" image_tag="${image_tag}-ee"
} }
} }
update_helm_release() { update_helm_release() {
chart=$1 chart=$1
HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')"
# Update the chart version # Update the chart version
sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
# Update image tags # Update image tags
sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
# Commit the changes # Commit the changes
git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
git commit -m "chore(helm): Updating $chart image release" git commit -m "chore(helm): Updating $chart image release"
} }
function build_api(){ function build_api() {
destination="_assist" destination="_assist"
[[ $1 == "ee" ]] && { [[ $1 == "ee" ]] && {
destination="_assist_ee" destination="_assist_ee"
} }
[[ -d ../${destination} ]] && { [[ -d ../${destination} ]] && {
echo "Removing previous build cache" echo "Removing previous build cache"
rm -rf ../${destination} rm -rf ../${destination}
} }
cp -R ../assist ../${destination} cp -R ../assist ../${destination}
cd ../${destination} cd ../${destination}
@ -68,5 +69,5 @@ function build_api(){
check_prereq check_prereq
build_api $1 build_api $1
if [[ $PATCH -eq 1 ]]; then if [[ $PATCH -eq 1 ]]; then
update_helm_release assist update_helm_release assist
fi fi

View file

@ -92,4 +92,4 @@ function build_api() {
} }
check_prereq check_prereq
build_api $1 $2 build_api i1 i2

View file

@ -9,19 +9,20 @@
# Helper function # Helper function
exit_err() { exit_err() {
err_code=$1 err_code=$1
if [[ $err_code != 0 ]]; then if [[ $err_code != 0 ]]; then
exit "$err_code" exit "$err_code"
fi fi
} }
source ../scripts/lib/_docker.sh
app="assist-stats" # Set the app variable to "chalice" app="assist-stats" # Set the app variable to "chalice"
environment=$1 environment=$1
git_sha=$(git rev-parse --short HEAD) git_sha=$(git rev-parse --short HEAD)
image_tag=${IMAGE_TAG:-git_sha} image_tag=${IMAGE_TAG:-git_sha}
envarg="default-foss" envarg="default-foss"
chart="$app" # Use the app variable here chart="$app" # Use the app variable here
check_prereq() { check_prereq() {
which docker || { which docker || {
echo "Docker not installed, please install docker." echo "Docker not installed, please install docker."
@ -32,31 +33,31 @@ check_prereq() {
[[ $1 == ee ]] && ee=true [[ $1 == ee ]] && ee=true
[[ $PATCH -eq 1 ]] && { [[ $PATCH -eq 1 ]] && {
image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')"
[[ $ee == "true" ]] && { [[ $ee == "true" ]] && {
image_tag="${image_tag}-ee" image_tag="${image_tag}-ee"
} }
} }
update_helm_release() { update_helm_release() {
[[ $ee == "true" ]] && return [[ $ee == "true" ]] && return
HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')"
# Update the chart version # Update the chart version
sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
# Update image tags # Update image tags
sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
# Commit the changes # Commit the changes
git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
git commit -m "chore(helm): Updating $chart image release" git commit -m "chore(helm): Updating $chart image release"
} }
function build_api(){ function build_api() {
destination="_assist_stats" destination="_assist_stats"
[[ $1 == "ee" ]] && { [[ $1 == "ee" ]] && {
destination="_assist_stats_ee" destination="_assist_stats_ee"
} }
[[ -d ../${destination} ]] && { [[ -d ../${destination} ]] && {
echo "Removing previous build cache" echo "Removing previous build cache"
rm -rf ../${destination} rm -rf ../${destination}
} }
cp -R ../assist-stats ../${destination} cp -R ../assist-stats ../${destination}
cd ../${destination} || exit_err 100 cd ../${destination} || exit_err 100
@ -86,5 +87,5 @@ check_prereq
build_api $environment build_api $environment
echo buil_complete echo buil_complete
if [[ $PATCH -eq 1 ]]; then if [[ $PATCH -eq 1 ]]; then
update_helm_release update_helm_release
fi fi

View file

@ -14,35 +14,36 @@ check_prereq() {
exit 1 exit 1
} }
} }
source ../scripts/lib/_docker.sh
[[ $1 == ee ]] && ee=true [[ $1 == ee ]] && ee=true
[[ $PATCH -eq 1 ]] && { [[ $PATCH -eq 1 ]] && {
image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')"
[[ $ee == "true" ]] && { [[ $ee == "true" ]] && {
image_tag="${image_tag}-ee" image_tag="${image_tag}-ee"
} }
} }
update_helm_release() { update_helm_release() {
chart=$1 chart=$1
HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')"
# Update the chart version # Update the chart version
sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
# Update image tags # Update image tags
sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
# Commit the changes # Commit the changes
git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
git commit -m "chore(helm): Updating $chart image release" git commit -m "chore(helm): Updating $chart image release"
} }
function build_api(){ function build_api() {
destination="_peers" destination="_peers"
[[ $1 == "ee" ]] && { [[ $1 == "ee" ]] && {
destination="_peers_ee" destination="_peers_ee"
} }
[[ -d ../${destination} ]] && { [[ -d ../${destination} ]] && {
echo "Removing previous build cache" echo "Removing previous build cache"
rm -rf ../${destination} rm -rf ../${destination}
} }
cp -R ../peers ../${destination} cp -R ../peers ../${destination}
cd ../${destination} cd ../${destination}
@ -68,5 +69,5 @@ function build_api(){
check_prereq check_prereq
build_api $1 build_api $1
if [[ $PATCH -eq 1 ]]; then if [[ $PATCH -eq 1 ]]; then
update_helm_release peers update_helm_release peers
fi fi

View file

@ -13,6 +13,7 @@ image_name="sourcemapreader"
git_sha=$(git rev-parse --short HEAD) git_sha=$(git rev-parse --short HEAD)
image_tag=${IMAGE_TAG:-git_sha} image_tag=${IMAGE_TAG:-git_sha}
envarg="default-foss" envarg="default-foss"
source ../scripts/lib/_docker.sh
check_prereq() { check_prereq() {
which docker || { which docker || {
@ -24,31 +25,31 @@ check_prereq() {
[[ $1 == ee ]] && ee=true [[ $1 == ee ]] && ee=true
[[ $PATCH -eq 1 ]] && { [[ $PATCH -eq 1 ]] && {
image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" image_tag="$(grep -ER ^.ppVersion ../scripts/helmcharts/openreplay/charts/$chart | xargs | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')"
[[ $ee == "true" ]] && { [[ $ee == "true" ]] && {
image_tag="${image_tag}-ee" image_tag="${image_tag}-ee"
} }
} }
update_helm_release() { update_helm_release() {
chart=$1 chart=$1
HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')" HELM_TAG="$(grep -iER ^version ../scripts/helmcharts/openreplay/charts/$chart | awk '{print $2}' | awk -F. -v OFS=. '{$NF += 1 ; print}')"
# Update the chart version # Update the chart version
sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml sed -i "s#^version.*#version: $HELM_TAG# g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
# Update image tags # Update image tags
sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml sed -i "s#ppVersion.*#ppVersion: \"$image_tag\"#g" ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
# Commit the changes # Commit the changes
git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml git add ../scripts/helmcharts/openreplay/charts/$chart/Chart.yaml
git commit -m "chore(helm): Updating $chart image release" git commit -m "chore(helm): Updating $chart image release"
} }
function build_api(){ function build_api() {
destination="_smr" destination="_smr"
[[ $1 == "ee" ]] && { [[ $1 == "ee" ]] && {
destination="_smr_ee" destination="_smr_ee"
} }
[[ -d ../${destination} ]] && { [[ -d ../${destination} ]] && {
echo "Removing previous build cache" echo "Removing previous build cache"
rm -rf ../${destination} rm -rf ../${destination}
} }
cp -R ../sourcemapreader ../${destination} cp -R ../sourcemapreader ../${destination}
cd ../${destination} cd ../${destination}
@ -78,5 +79,5 @@ check_prereq
build_api $1 build_api $1
echo buil_complete echo buil_complete
if [[ $PATCH -eq 1 ]]; then if [[ $PATCH -eq 1 ]]; then
update_helm_release sourcemapreader update_helm_release sourcemapreader
fi fi