Skip to content

Instantly share code, notes, and snippets.

@garystafford
Last active September 18, 2018 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garystafford/1f1a27937ed0ab0463f316784f45f577 to your computer and use it in GitHub Desktop.
Save garystafford/1f1a27937ed0ab0463f316784f45f577 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
# author: Gary A. Stafford
# site: https://programmaticponderings.com
# license: MIT License
IMAGE_REPOSITORY=<your_image_repo>
IMAGE_NAME=<your_image_name>
GCP_PROJECT=<your_project>
TAG=<your_image_tag>
# Build Spring Boot app
./gradlew clean build
# Build Docker file
docker build -f Docker/Dockerfile --no-cache -t ${IMAGE_REPOSITORY}/${IMAGE_NAME}:${TAG} .
# Push image to Docker Hub
docker push ${IMAGE_REPOSITORY}/${IMAGE_NAME}:${TAG}
# Push image to GCP Container Registry (GCR)
docker tag ${IMAGE_REPOSITORY}/${IMAGE_NAME}:${TAG} gcr.io/${GCP_PROJECT}/${IMAGE_NAME}:${TAG}
docker push gcr.io/${GCP_PROJECT}/${IMAGE_NAME}:${TAG}
# Re-deploy Workload (containerized app) to GKE
kubectl replace --force -f gke/${IMAGE_NAME}.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment