Skip to content

Commit 2b36b2b

Browse files
authored
feat: update Cloud Run samples to use Artifact Registry (#1518)
1 parent d8ff103 commit 2b36b2b

File tree

6 files changed

+45
-18
lines changed

6 files changed

+45
-18
lines changed

eventarc/generic/README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,26 @@ This sample shows how to create a service that receives and prints generic event
99

1010
## Quickstart
1111

12+
Set your environment variables:
13+
14+
```
15+
export GOOGLE_CLOUD_PROJECT=<PROJECT_ID>
16+
export GOOGLE_CLOUD_REGION=<REGION>
17+
```
18+
19+
Create an Artifact Registry:
20+
21+
```
22+
gcloud artifacts repositories create containers --repository-format docker --location ${GOOGLE_CLOUD_REGION}
23+
```
24+
1225
Deploy your Cloud Run service:
1326

1427
```
1528
gcloud builds submit \
16-
--tag gcr.io/$(gcloud config get-value project)/eventarc-generic
29+
--tag ${GOOGLE_CLOUD_REGION}-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/containers/eventarc-generic
1730
gcloud run deploy eventarc-generic \
18-
--image gcr.io/$(gcloud config get-value project)/eventarc-generic
31+
--image ${GOOGLE_CLOUD_REGION}-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/containers/eventarc-generic
1932
```
2033

2134
## Test

eventarc/generic/e2e_test_setup.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
steps:
1616
- # Build the renderer image
1717
name: gcr.io/cloud-builders/docker:latest
18-
args: ['build', '--tag=gcr.io/$PROJECT_ID/eventarc-${_SUFFIX}', '.']
18+
args: ['build', '--tag=us-docker.pkg.dev/$PROJECT_ID/containers/eventarc-${_SUFFIX}', '.']
1919

2020
- # Push the container image to Container Registry
2121
name: gcr.io/cloud-builders/docker
22-
args: ['push', 'gcr.io/$PROJECT_ID/eventarc-${_SUFFIX}']
22+
args: ['push', 'us-docker.pkg.dev/$PROJECT_ID/containers/eventarc-${_SUFFIX}']
2323

2424
- # Deploy to Cloud Run
2525
name: gcr.io/google.com/cloudsdktool/cloud-sdk
@@ -28,11 +28,11 @@ steps:
2828
- run
2929
- deploy
3030
- eventarc-${_SUFFIX}
31-
- --image=gcr.io/$PROJECT_ID/eventarc-${_SUFFIX}
31+
- --image=us-docker.pkg.dev/$PROJECT_ID/containers/eventarc-${_SUFFIX}
3232
- --region=us-central1
3333
- --platform=managed
3434
- --no-allow-unauthenticated
3535
- --set-env-vars=NAME=Test
3636

3737
images:
38-
- 'gcr.io/$PROJECT_ID/eventarc-${_SUFFIX}'
38+
- 'us-docker.pkg.dev/$PROJECT_ID/containers/eventarc-${_SUFFIX}'

eventarc/pubsub/e2e_test_setup.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
steps:
1616
- # Build the renderer image
1717
name: gcr.io/cloud-builders/docker:latest
18-
args: ['build', '--tag=gcr.io/$PROJECT_ID/eventarc-${_SUFFIX}', '.']
18+
args: ['build', '--tag=us-docker.pkg.dev/$PROJECT_ID/containers/eventarc-${_SUFFIX}', '.']
1919

2020
- # Push the container image to Container Registry
2121
name: gcr.io/cloud-builders/docker
22-
args: ['push', 'gcr.io/$PROJECT_ID/eventarc-${_SUFFIX}']
22+
args: ['push', 'us-docker.pkg.dev/$PROJECT_ID/containers/eventarc-${_SUFFIX}']
2323

2424
- # Deploy to Cloud Run
2525
name: gcr.io/google.com/cloudsdktool/cloud-sdk
@@ -28,11 +28,11 @@ steps:
2828
- run
2929
- deploy
3030
- eventarc-${_SUFFIX}
31-
- --image=gcr.io/$PROJECT_ID/eventarc-${_SUFFIX}
31+
- --image=us-docker.pkg.dev/$PROJECT_ID/containers/eventarc-${_SUFFIX}
3232
- --region=us-central1
3333
- --platform=managed
3434
- --no-allow-unauthenticated
3535
- --set-env-vars=NAME=Test
3636

3737
images:
38-
- 'gcr.io/$PROJECT_ID/eventarc-${_SUFFIX}'
38+
- 'us-docker.pkg.dev/$PROJECT_ID/containers/eventarc-${_SUFFIX}'

run/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ For more Cloud Run samples beyond Ruby, see the main list in the [Cloud Run Samp
2222
git clone https://github.com/GoogleCloudPlatform/ruby-docs-samples.git
2323
```
2424

25+
1. Create an Artifact Registry:
26+
27+
```sh
28+
gcloud artifacts repositories create containers --repository-format docker --location ${GOOGLE_CLOUD_REGION}
29+
```
30+
2531
## How to run a sample locally
2632

2733
1. [Install docker locally](https://docs.docker.com/install/)
@@ -75,14 +81,14 @@ For more Cloud Run samples beyond Ruby, see the main list in the [Cloud Run Samp
7581
1. Build your container image using Cloud Build, by running the following command from the directory containing the Dockerfile:
7682

7783
```sh
78-
gcloud builds submit --tag gcr.io/${GOOGLE_CLOUD_PROJECT}/${SAMPLE}
84+
gcloud builds submit --tag ${GOOGLE_CLOUD_REGION}-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/containers/${SAMPLE}
7985
```
8086

8187
1. Deploy the container image using the following command:
8288

8389
```sh
8490
gcloud run deploy ${SAMPLE} \
85-
--image gcr.io/${GOOGLE_CLOUD_PROJECT}/${SAMPLE}
91+
--image ${GOOGLE_CLOUD_REGION}-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/containers/${SAMPLE}
8692
```
8793

8894
See [Building containers][run_build] and [Deploying container images][run_deploy]

run/helloworld/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ This sample shows how to deploy a Hello World application to Cloud Run.
1616
```sh
1717
git clone https://github.com/GoogleCloudPlatform/ruby-docs-samples.git
1818
```
19+
1. Create an Artifact Registry:
20+
21+
```sh
22+
gcloud artifacts repositories create containers --repository-format docker --location ${GOOGLE_CLOUD_REGION}
23+
```
1924

2025
## Build
2126

@@ -48,11 +53,14 @@ bundle exec rspec
4853
# Set an environment variable with your GCP Project ID
4954
export GOOGLE_CLOUD_PROJECT=<PROJECT_ID>
5055

56+
# Set an environment variable with your Google Cloud region
57+
export GOOGLE_CLOUD_REGION=<REGION>
58+
5159
# Submit a build using Google Cloud Build
52-
gcloud builds submit --tag gcr.io/${GOOGLE_CLOUD_PROJECT}/helloworld
60+
gcloud builds submit --tag ${GOOGLE_CLOUD_REGION}-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/containers/helloworld
5361

5462
# Deploy to Cloud Run
55-
gcloud run deploy helloworld --image gcr.io/${GOOGLE_CLOUD_PROJECT}/helloworld
63+
gcloud run deploy helloworld --image ${GOOGLE_CLOUD_REGION}-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/containers/helloworld
5664
```
5765

5866
Visit your deployed container by opening the service URL in a web browser.

run/helloworld/e2e_test_setup.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
steps:
1616
- # Build the renderer image
1717
name: gcr.io/cloud-builders/docker:latest
18-
args: ['build', '--tag=gcr.io/$PROJECT_ID/helloworld-${_SUFFIX}', '.']
18+
args: ['build', '--tag=us-docker.pkg.dev/$PROJECT_ID/containers/helloworld-${_SUFFIX}', '.']
1919

2020
- # Push the container image to Container Registry
2121
name: gcr.io/cloud-builders/docker
22-
args: ['push', 'gcr.io/$PROJECT_ID/helloworld-${_SUFFIX}']
22+
args: ['push', 'us-docker.pkg.dev/$PROJECT_ID/containers/helloworld-${_SUFFIX}']
2323

2424
- # Deploy to Cloud Run
2525
name: gcr.io/google.com/cloudsdktool/cloud-sdk
@@ -28,11 +28,11 @@ steps:
2828
- run
2929
- deploy
3030
- helloworld-${_SUFFIX}
31-
- --image=gcr.io/$PROJECT_ID/helloworld-${_SUFFIX}
31+
- --image=us-docker.pkg.dev/$PROJECT_ID/containers/helloworld-${_SUFFIX}
3232
- --region=us-central1
3333
- --platform=managed
3434
- --no-allow-unauthenticated
3535
- --set-env-vars=NAME=Test
3636

3737
images:
38-
- 'gcr.io/$PROJECT_ID/helloworld-${_SUFFIX}'
38+
- 'us-docker.pkg.dev/$PROJECT_ID/containers/helloworld-${_SUFFIX}'

0 commit comments

Comments
 (0)