Last active
May 2, 2020 14:38
-
-
Save TiagoGouvea/d5dbb7b2d41bcc1b0d8741d22bacb0b2 to your computer and use it in GitHub Desktop.
Revisions
-
TiagoGouvea revised this gist
May 2, 2020 . 1 changed file with 8 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/usr/bin/env bash echo -e "\nDeploy remote instance" echo -e "\n# 1/4 - Loading and setting options..." ## Show commands (if you want to check, uncomment it) #set -x @@ -15,19 +15,18 @@ source config.sh gcloud config set project ${PROJECT} gcloud config set compute/zone ${ZONE} # Build and tag backend echo -e "\n# 2/4 - Building (and tagging) docker image..." cd ../backend/ docker build -f Dockerfile -t ${IMAGE_TAG} . docker tag ${IMAGE_TAG} ${CONTAINER_IMAGE} # Push image echo -e "\n# 3/4 - Pushing image to Google Container Registry..." docker push ${CONTAINER_IMAGE} # Update remote instance echo -e "\n# 4/4 - Pulling and starting remote container..." gcloud beta compute --project ${PROJECT} ssh ${INSTANCE_NAME} --zone ${ZONE} --command="cd ${REMOTE_PATH} && docker stop \$(docker ps -aq) || true && docker rm \$(docker ps -aq) || true && docker run -d -p 80:8080 --name=${IMAGE_TAG} ${CONTAINER_IMAGE} " echo -e "\nInstance updated!" -
TiagoGouvea revised this gist
May 1, 2020 . 1 changed file with 1 addition and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -28,11 +28,6 @@ echo -e "\n# 4/X - Updating remote config files..." cd ../deployment/ echo -e "\n# 4/X - Pulling and starting remote container..." gcloud beta compute --project ${PROJECT} ssh ${INSTANCE_NAME} --zone ${ZONE} --command="cd ${REMOTE_PATH} && docker stop \$(docker ps -aq) && docker rm \$(docker ps -aq) && docker run -d -p 80:8080 --name=${IMAGE_TAG} ${CONTAINER_IMAGE} " echo -e "\nInstance updated!" -
TiagoGouvea created this gist
May 1, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ #!/usr/bin/env bash echo -e "\nDeploy remote instance" echo -e "\n# 1/X - Loading and setting options..." ## Show commands (if you want to check, uncomment it) #set -x ## Stop on errors set -e ## Include config source config.sh ## Set GCP compute zone gcloud config set project ${PROJECT} gcloud config set compute/zone ${ZONE} echo -e "\n# 2/X - Building (and tagging) docker image..." # Build and push backend cd ../backend/ docker build -f Dockerfile -t ${IMAGE_TAG} . docker tag ${IMAGE_TAG} ${CONTAINER_IMAGE} echo -e "\n# 3/X - Pushing image to Google Container Registry..." docker push ${CONTAINER_IMAGE} echo -e "\n# 4/X - Updating remote config files..." cd ../deployment/ echo -e "\n# 4/X - Pulling and starting remote container..." if [[ ${DETACHED} == "1" ]]; then DETACHED="-d" else DETACHED="" fi gcloud beta compute --project ${PROJECT} ssh ${INSTANCE_NAME} --zone ${ZONE} --command="cd ${REMOTE_PATH} && docker stop \$(docker ps -aq) && docker rm \$(docker ps -aq) && docker run -p 80:8080 --name=${IMAGE_TAG} ${DETACHED} ${CONTAINER_IMAGE} " echo -e "\nInstance updated!"