A Google Cloud project groups services for an application. Before using Cloud Run, create the project, link it to a billing account, and explicitly enable the services it needs. section 14.4
Prepare a project for container workloads:
- Create a uniquely named project with gcloud projects create. section 14.4
- Link the project to a billing account before using paid cloud services. section 14.4
- Enable required services explicitly, such as Artifact Registry and Cloud Run. section 14.4
- Create an Artifact Registry repository inside the project and use the project name in the image reference. section 14.4
A project for Cloud Run
A project named diamol2ees can contain the ch14 Artifact Registry repository and Cloud Run workloads. An image can be addressed as us-east1-docker.pkg.dev/diamol2ees/ch14/hello-cloud, then deployed as a Cloud Run job or service. section 14.4
# initialize your CLI (if you haven't already): gcloud init # store variables - you will need a unique project name, # and any region will do; with PowerShell: $REGION='us-east1' $PROJECT='<your-project-name>' # OR Linux shell: REGION='us-east1' PROJECT='<your-project-name>' # create the project: gcloud projects create $PROJECT # list your billing accounts: gcloud billing accounts list # link your new project to the billing account: gcloud billing projects link $PROJECT ` --billing-account=<your-billing-account-id> # and now enable the Artifact Registry service: gcloud services enable artifactregistry.googleapis.com ` --project=$PROJECT
Use the command sequence to initialize gcloud, create a project, inspect billing accounts, link billing, and enable Artifact Registry. section 14.4
# create the registry in your project:
gcloud artifacts repositories create ch14 `
--repository-format=docker --project=$PROJECT --location=$REGION
# print the information - this includes the registry domain:
gcloud artifacts repositories describe ch14 `
--project=$PROJECT --location=$REGION
# store the domain in a variable - PowerShell:
$REGISTRY="${REGION}-docker.pkg.dev"
# OR Linux shell:
REGISTRY="${REGION}-docker.pkg.dev"
# authenticate the registry with the Docker CLI:
gcloud auth configure-docker --quiet $REGISTRY
# pull the source image:
docker pull ghcr.io/diamol2e/ch14-hello-cloud
# tag it with your Artifact Registry reference:
docker tag ghcr.io/diamol2e/ch14-hello-cloud `
"$REGISTRY/$PROJECT/ch14/hello-cloud"
# and push:
docker push "$REGISTRY/$PROJECT/ch14/hello-cloud"
Continue the setup by creating a regional Docker repository, authenticating Docker, tagging an image with the project path, and pushing it. section 14.4


