Created
February 17, 2021 21:45
-
-
Save sohiniroych/df72a37150a26e753eab07cf9f041b73 to your computer and use it in GitHub Desktop.
cloudbuild.yaml
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
| steps: | |
| # Step 1: pull the container image if it is already built, if fails do not exit | |
| - name: 'gcr.io/cloud-builders/docker' | |
| entrypoint: 'bash' | |
| args: | |
| - '-c' | |
| - 'docker pull gcr.io/$PROJECT_ID/appcicd:latest || exit 0' | |
| # Step 2: Create a docker image if none exists, esle load existing one | |
| - name: 'gcr.io/cloud-builders/docker' | |
| args: | |
| - 'build' | |
| - '-t' | |
| - 'gcr.io/$PROJECT_ID/appcicd:latest' | |
| - '-t' | |
| - 'gcr.io/$PROJECT_ID/appcicd:$COMMIT_SHA' | |
| - '--cache-from' | |
| - 'gcr.io/$PROJECT_ID/appcicd:latest' | |
| - '.' | |
| # Step 3: Push the docker image to the run | |
| - name: 'gcr.io/cloud-builders/docker' | |
| args: | |
| - 'push' | |
| - 'gcr.io/$PROJECT_ID/appcicd' | |
| # Step 4: Deploy container image to Cloud Run | |
| - name: 'gcr.io/cloud-builders/gcloud' | |
| args: | |
| - 'run' | |
| - 'deploy' | |
| - 'flaskappml' | |
| - '--image' | |
| - 'gcr.io/$PROJECT_ID/appcicd:latest' | |
| - '--region' | |
| - 'us-central1' | |
| - '--platform' | |
| - 'managed' | |
| - '--allow-unauthenticated' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment