@@ -36,9 +36,9 @@ For more Cloud Run samples beyond Python, see the main list in the [Cloud Run Sa
36
36
2. [Build the sample container](https://cloud.google.com/run/docs/building/containers#building_locally_and_pushing_using_docker):
37
37
38
38
```
39
- export SAMPLE=$sample
39
+ export SAMPLE=<SAMPLE_NAME>
40
40
cd $SAMPLE
41
- docker build --tag $sample .
41
+ docker build --tag $SAMPLE .
42
42
```
43
43
44
44
3. [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
57
57
-v $PWD:/app $SAMPLE
58
58
```
59
59
60
- Injecting your service account key:
60
+ Injecting your service account key for access to GCP services :
61
61
62
62
```
63
+ # Set the name of the service account key within the container
63
64
export SA_KEY_NAME=my-key-name-123
65
+
64
66
PORT=8080 && docker run --rm \
65
- -p 8080:${PORT} -e PORT=${PORT} \
67
+ -p 8080:${PORT} \
68
+ -e PORT=${PORT} \
66
69
-e GOOGLE_APPLICATION_CREDENTIALS=/tmp/keys/${SA_KEY_NAME}.json \
67
70
-v $GOOGLE_APPLICATION_CREDENTIALS:/tmp/keys/${SA_KEY_NAME}.json:ro \
68
7
8000
1
-v $PWD:/app $SAMPLE
69
72
```
70
73
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
+
71
83
## Deploying
72
84
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
73
91
```
74
92
gcloud builds submit --tag gcr.io/${GOOGLE_CLOUD_PROJECT}/${SAMPLE}
75
- gcloud beta run deploy $SAMPLE \
76
- # Needed for Manual Logging sample.<
8000
/span>
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}
79
98
```
80
99
81
100
See [Building containers][run_build] and [Deploying container images][run_deploy]
@@ -88,3 +107,4 @@ for more information.
88
107
[pubsub]: pubsub/
89
108
[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
90
109
[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