Skip to content

Commit

Permalink
Add GCP required annotation when pushing to GCP staging and prod
Browse files Browse the repository at this point in the history
  • Loading branch information
carminevassallo committed Jan 22, 2025
1 parent 723b6ad commit cd6be2b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .cirrus/multi-arch-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export DOCKER_BUILDKIT=1
for i in $(seq 1 3); do
if docker buildx build --platform linux/amd64,linux/arm64 --tag "$1:$2" --push $3; then
if docker buildx build --platform linux/amd64,linux/arm64 --tag "$1:$2" --label "com.googleapis.cloudmarketplace.product.service.name=services/sonarqube-dce" --push $3; then
echo "[Success]: Buildx, attempt ${i}"
exit 0
fi
Expand Down
18 changes: 18 additions & 0 deletions .cirrus/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ multi_arch_build_gcp_prod_task:
- echo "Promote the ${PUBLIC_IMAGE_NAME}:${CURRENT_VERSION}-datacenter-app images supporting two architectures (linux/amd64 and linux/arm64) to the GCP registry ${GCLOUD_REGISTRY}"
- docker tag "${PUBLIC_IMAGE_NAME}:${CURRENT_VERSION}-datacenter-app" "${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}:${CURRENT_VERSION}"
- docker tag "${PUBLIC_IMAGE_NAME}:${CURRENT_VERSION}-datacenter-app" "${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}:${CURRENT_MINOR_VERSION}"
- echo -e "FROM ${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}:${CURRENT_VERSION}\nLABEL com.googleapis.cloudmarketplace.product.service.name=services/sonarqube-dce" | docker build -t ${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}:${CURRENT_VERSION} -
- echo -e "FROM ${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}:${CURRENT_MINOR_VERSION}\nLABEL com.googleapis.cloudmarketplace.product.service.name=services/sonarqube-dce" | docker build -t ${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}:${CURRENT_MINOR_VERSION} -
- docker push "${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}:${CURRENT_VERSION}"
- docker push "${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}:${CURRENT_MINOR_VERSION}"
- echo "Promote the ${PUBLIC_IMAGE_NAME}:${CURRENT_VERSION}-datacenter-search images supporting two architectures (linux/amd64 and linux/arm64) to the GCP registry ${GCLOUD_REGISTRY}"
- docker tag "${PUBLIC_IMAGE_NAME}:${CURRENT_VERSION}-datacenter-search" "${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}/sonarqube-dce-search:${CURRENT_VERSION}"
- docker tag "${PUBLIC_IMAGE_NAME}:${CURRENT_VERSION}-datacenter-search" "${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}/sonarqube-dce-search:${CURRENT_MINOR_VERSION}"
- echo -e "FROM ${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}/sonarqube-dce-search:${CURRENT_VERSION}\nLABEL com.googleapis.cloudmarketplace.product.service.name=services/sonarqube-dce" | docker build -t ${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}/sonarqube-dce-search:${CURRENT_VERSION} -
- echo -e "FROM ${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}/sonarqube-dce-search:${CURRENT_MINOR_VERSION}\nLABEL com.googleapis.cloudmarketplace.product.service.name=services/sonarqube-dce" | docker build -t ${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}/sonarqube-dce-search:${CURRENT_MINOR_VERSION} -
- docker push "${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}/sonarqube-dce-search:${CURRENT_VERSION}"
- docker push "${GCLOUD_REGISTRY}/${GCLOUD_PRODUCT_NAME}/sonarqube-dce-search:${CURRENT_MINOR_VERSION}"

Expand Down Expand Up @@ -128,6 +132,20 @@ multi_arch_build_2025_x_task:
- version: ${NEXT_VERSION}/datacenter/search
tag: ${NEXT_VERSION}-datacenter-search

multi_arch_build_task_template: &multi_arch_build_task_template
ec2_instance:
<<: *VM_TEMPLATE
login_script:
- docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
setup_script:
- docker run -t --rm --privileged tonistiigi/binfmt --install all
- docker buildx create --name multibuilder --driver docker-container
- docker buildx use multibuilder
- docker buildx inspect --bootstrap
build_script:
- echo "Build the ${STAGING_IMAGE_NAME}:${tag} image supporting two architectures, linux/amd64 and linux/arm64"
- .cirrus/multi-arch-build.sh ${STAGING_IMAGE_NAME} ${tag} ${version}

multi_arch_build_community_build_task:
<<: *multi_arch_build_task_template
skip: "!changesInclude('community-build/*') && !changesInclude('.cirrus/*')"
Expand Down

0 comments on commit cd6be2b

Please sign in to comment.