NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#!/bin/bash
set -euo pipefail

cat << EOF
=========================================================
buildspec build.sh -- This Script Servers the Pupose of taking all the actions needed before deployment to higher environments
---- PRE PUBLISH STEPS ----
Phase 1. Execute Unit Tests
Phase 2. NexusIQ Scan
Phase 3. Build Docker Image (We will build or extract depending on Branch)
Phase 4. Execute Twist Lock Scan (We Will Scan when it is the Master or Release Branch...)
---- PUBLISH STEPS ----
Phase 5 Tag & Publish Docker Image To Nexus (We will tag and publish depending on Branch)
Phase 6. Publish Helm chart to Nexus (We Will Publish depending on Branch)
---- DEPLOY STEPS ----
Phase 7. Deploy Helm Chart (Deployment of the Docker Image & Applicaiton)
=========================================================
EOF

#Start Set Variables
[[ $CODEBUILD_RESOLVED_SOURCE_VERSION ]]
[[ $CODEBUILD_SOURCE_VERSION ]]
[[ $GIT_BRANCH_NAME ]]
[[ $BRANCH ]]

echo "CODEBUILD_SOURCE_VERSION - " $CODEBUILD_SOURCE_VERSION
echo "CODEBUILD_RESOLVED_SOURCE_VERSION - " $CODEBUILD_RESOLVED_SOURCE_VERSION
echo "GIT_BRANCH_NAME - " $GIT_BRANCH_NAME
echo "BRANCH -" $BRANCH



if [[ "${GIT_BRANCH_NAME}" == *"main"* ]]; then
echo "Release build... Tagging as such..."
export readonly DATE_TIME=$( date '+%F' )
export readonly COMMIT_HASH="$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)"
export readonly IMAGE_TAG="${GIT_BRANCH_NAME}-${DATE_TIME}-${COMMIT_HASH}"
echo $IMAGE_TAG
else
export readonly COMMIT_HASH="$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)"
export readonly IMAGE_TAG=$BRANCH-$COMMIT_HASH
fi
export readonly DR_REGION="us-west-2"
export readonly REPOSITORY1_URI="$PIPELINE_ACCOUNT_NUMBER.dkr.ecr.$REGION.amazonaws.com/$ECR_REPO_NAME"
export readonly REPOSITORY1_URI_DR="$PIPELINE_ACCOUNT_NUMBER.dkr.ecr.$DR_REGION.amazonaws.com/$ECR_REPO_NAME"
export readonly CURRENT_HELM_VERSION=$(yq -r .version ./helm-chart/Chart.yaml)
export readonly NEW_HELM_VERSION=${CURRENT_HELM_VERSION}-${IMAGE_TAG}
#End Set Variables


#Phase 1. Build Docker Image and Run Pytest
echo "Starting... Phase 4. Build Docker Image..."
if [ -z "$IMAGE_TAG" ] || [ "$IMAGE_TAG" == 'null' ]; then
echo "Error. IMAGE_TAG is empty" 1>&2
exit 1;
fi

docker build -t $REPOSITORY1_URI:latest ./application-source --progress=plain --no-cache



echo "Ending... Phase 4. Build Docker Image...n"


#Phase 6. Tag & Publish Docker Image To ECR (We will tag and publish depending on Branch)
echo "Starting... Tag & Publish Docker Image To ECR..."
if [ -z "$IMAGE_TAG" ] || [ "$IMAGE_TAG" == 'null' ]; then
echo "Error. IMAGE_TAG is empty" 1>&2
exit 1;
fi

docker_publish () {
echo "Logging into ECR for docker push"
# $(aws ecr get-login --no-include-email --region $REGION --registry-ids $PIPELINE_ACCOUNT_NUMBER)
aws ecr get-login-password --region $REGION | docker login --username AWS --password-stdin $PIPELINE_ACCOUNT_NUMBER.dkr.ecr.$REGION.amazonaws.com
echo "Pushing docker image '$REPOSITORY1_URI:$IMAGE_TAG' to ECR..."
docker tag ${REPOSITORY1_URI}:latest ${REPOSITORY1_URI}:${IMAGE_TAG}
docker push $REPOSITORY1_URI:$IMAGE_TAG

# echo "Logging into DR ECR for docker push"
# # aws ecr get-login --region $DR_REGION --no-include-email
# aws ecr get-login-password --region $DR_REGION | docker login --username AWS --password-stdin $PIPELINE_ACCOUNT_NUMBER.dkr.ecr.$DR_REGION.amazonaws.com
# # aws ecr get-login --region $DR_REGION --no-include-email | docker login --username AWS --password-stdin $PIPELINE_ACCOUNT_NUMBER.dkr.ecr.$DR_REGION.amazonaws.com
# echo "Pushing docker image '$REPOSITORY1_URI_DR:$IMAGE_TAG' to ECR..."
# docker tag ${REPOSITORY1_URI}:latest ${REPOSITORY1_URI_DR}:${IMAGE_TAG}
# docker push $REPOSITORY1_URI_DR:$IMAGE_TAG
}

docker_publish
echo "Ending... Tag & Publish Docker Image To ECR...n"


#Phase 7. Publish Helm chart to ECR (We Will Publish depending on Branch)
echo "Starting... Publish Helm chart to ECR..."
helm_publish () {
echo "Setting Image Repo and Tag In Helm Chart..."
yq -yi --arg repo $REPOSITORY1_URI '.image.repo = $repo' ./helm-chart/values.yaml
yq -yi --arg tag $IMAGE_TAG '.image.tag = $tag' ./helm-chart/values.yaml
cat ./helm-chart/values.yaml

echo "Setting Helm Versions ${NEW_HELM_VERSION}..."
yq -yi --arg version $NEW_HELM_VERSION '.version = $version' ./helm-chart/Chart.yaml
cat ./helm-chart/Chart.yaml

echo "Packaging Helm Chart..."
helm package ./helm-chart
HELM_CHART_NAME=$(yq -r .name ./helm-chart/Chart.yaml)

echo "Logging into ECR for helm push..."
aws ecr get-login-password --region $REGION | helm registry login --username AWS --password-stdin $PIPELINE_ACCOUNT_NUMBER.dkr.ecr.$REGION.amazonaws.com

echo "Publishing helm chart to ECR..."
helm push $HELM_CHART_NAME-$NEW_HELM_VERSION.tgz oci://$PIPELINE_ACCOUNT_NUMBER.dkr.ecr.$REGION.amazonaws.com/

echo "Generate imagedefinitions.json for deployments..."
printf '{"name":"'"$HELM_CHART_NAME"'","imageUri":"'"$REPOSITORY1_URI:$IMAGE_TAG"'","helm_chart_name":"'"$HELM_CHART_NAME"'", "helm_chart_repo":"'"$PIPELINE_ACCOUNT_NUMBER.dkr.ecr.$REGION.amazonaws.com/$HELM_CHART_NAME"'","helmChartVersion":"'"$NEW_HELM_VERSION"'" }n' > imagedefinitions.json
cat imagedefinitions.json
}

helm_publish
echo "Ending... Published Helm chart to ECR...n"
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.