@@ -36,9 +36,9 @@ For more Cloud Run samples beyond Python, see the main list in the [Cloud Run Sa
36362. [Build the sample container](https://cloud.google.com/run/docs/building/containers#building_locally_and_pushing_using_docker):
3737
3838 ```
39- export SAMPLE=$sample
39+ export SAMPLE=<SAMPLE_NAME>
4040 cd $SAMPLE
41- docker build --tag $sample .
41+ docker build --tag $SAMPLE .
4242 ```
4343
44443. [Run containers locally](https://cloud.google.com/run/docs/testing/local)
@@ -57,25 +57,44 @@ For more Cloud Run samples beyond Python, see the main list in the [Cloud Run Sa
5757 -v $PWD:/app $SAMPLE
5858 ```
5959
60- Injecting your service account key:
60+ Injecting your service account key for access to GCP services :
6161
6262 ```
63+ # Set the name of the service account key within the container
6364 export SA_KEY_NAME=my-key-name-123
65+
6466 PORT=8080 && docker run --rm \
65- -p 8080:${PORT} -e PORT=${PORT} \
67+ -p 8080:${PORT} \
68+ -e PORT=${PORT} \
6669 -e GOOGLE_APPLICATION_CREDENTIALS=/tmp/keys/${SA_KEY_NAME}.json \
6770 -v $GOOGLE_APPLICATION_CREDENTIALS:/tmp/keys/${SA_KEY_NAME}.json:ro \
6871 -v $PWD:/app $SAMPLE
6972 ```
7073
74+ * Use the --volume (-v) flag to inject the credential file into the container
75+ (assumes you have already set your `GOOGLE_APPLICATION_CREDENTIALS`
76+ environment variable on your machine)
77+
78+ * Use the --environment (-e) flag to set the `GOOGLE_APPLICATION_CREDENTIALS`
79+ variable inside the container
80+
81+ Learn more about [testing your container image locally.][testing]
82+
7183## Deploying
7284
85+ 1. Set an environment variable with your GCP Project ID
86+ ```
87+ export GOOGLE_CLOUD_PROJECT=<PROJECT_ID>
88+ ```
89+
90+ 1. Submit a build using Google Cloud Build
7391```
7492gcloud builds submit --tag gcr.io/${GOOGLE_CLOUD_PROJECT}/${SAMPLE}
75- gcloud beta run deploy $SAMPLE \
76- # Needed for Manual Logging sample.
77- --set-env-var GOOGLE_CLOUD_PROJECT=${GOOGLE_CLOUD_PROJECT}
78- --image gcr.io/${GOOGLE_CLOUD_PROJECT}/${SAMPLE}
93+ ```
94+
95+ 1. Deploy to Cloud Run
96+ ```
97+ gcloud beta run deploy $SAMPLE --image gcr.io/${GOOGLE_CLOUD_PROJECT}/${SAMPLE}
7998```
8099
81100See [Building containers][run_build] and [Deploying container images][run_deploy]
@@ -88,3 +107,4 @@ for more information.
88107[pubsub]: pubsub/
89108[run_button_helloworld]: https://console.cloud.google.com/cloudshell/editor?shellonly=true&cloudshell_image=gcr.io/cloudrun/button&cloudshell_git_repo=https://github.com/knative/docs&cloudshell_working_dir=docs/serving/samples/hello-world/helloworld-python
90109[run_button_pubsub]: https://console.cloud.google.com/cloudshell/editor?shellonly=true&cloudshell_image=gcr.io/cloudrun/button&cloudshell_git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&cloudshell_working_dir=run/pubsub
110+ [testing]: https://cloud.google.com/run/docs/testing/local#running_locally_using_docker_with_access_to_services
0 commit comments