Created
January 24, 2021 07:08
-
-
Save mr-pascal/cf13b59de8ad4806f4421f924d24952a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#################################### | |
########### VARIABLES ############## | |
#################################### | |
GCP_PROJECT="YOUR_PROJECT_ID" | |
SERVICE_NAME="my-react-app" | |
REGION="europe-west1" | |
#################################### | |
###### GENERATED VARIABLES ######### | |
#################################### | |
VERSION="$(yarn run env | grep npm_package_version | sed 's/"npm_package_version": "//g' | sed 's/",//g' | sed 's/ //g')" | |
IMAGE_NAME="gcr.io/$GCP_PROJECT/$SERVICE_NAME" | |
IMAGE_NAME_VERSION="$IMAGE_NAME:$VERSION" | |
IMAGE_NAME_LATEST="$IMAGE_NAME:latest" | |
#################################### | |
############# BUILD ################ | |
#################################### | |
echo "Create Docker image via 'Cloud Build' ..." | |
gcloud builds submit \ | |
--tag "$IMAGE_NAME_VERSION" \ | |
--project $GCP_PROJECT | |
#################################### | |
############ TAGGING ############### | |
#################################### | |
echo "Add tags '$IMAGE_NAME_LATEST' and '$IMAGE_NAME_VERSION' to docker image..." | |
gcloud container images add-tag "$IMAGE_NAME_VERSION" $IMAGE_NAME_LATEST --quiet | |
#################################### | |
########### DEPLOYMENT ############# | |
#################################### | |
echo "Deploying Cloud Run Service '$SERVICE_NAME' to '$GCP_PROJECT' in '$REGION' ๐ ๐" | |
gcloud run deploy $SERVICE_NAME \ | |
--image "$IMAGE_NAME_VERSION" \ | |
--project $GCP_PROJECT \ | |
--platform managed \ | |
--region $REGION \ | |
--allow-unauthenticated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment