OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to upload public docker image to Artifact Registry in GCP

  • Thread starter Thread starter nprime496
  • Start date Start date
N

nprime496

Guest
There is the code to create to create a Cloud Run with an image from an Artifact Registry repository from the Terraform documentation.

Code:
resource "google_artifact_registry_repository" "my_repo" {
  location      = "us-west1"
  repository_id = "my-repository"
  format        = "DOCKER"
}

data "google_artifact_registry_docker_image" "my_image" {
  repository = google_artifact_registry_repository.my_repo.id
  image      = "my-image"
  tag        = "my-tag"
}

resource "google_cloud_run_v2_service" "default" {
 # ...

  template {
    containers {
      image = data.google_artifact_registry_docker_image.my_image.self_link
    }
  }
}

Here is the code to create a Cloud Run from a public image in GCP using Terraform from the Terraform documentation.

Code:
resource "google_cloud_run_v2_service" "default" {
  name     = "cloudrun-service"
  location = "us-central1"
  ingress = "INGRESS_TRAFFIC_ALL"

  template {
    containers {
      image = "us-docker.pkg.dev/cloudrun/container/hello"
    }
  }
}

But how to I upload a (dummy) public image to my Artifact registry to make my Cloud Run use it ?

More context:

I'd like to create an Artifact registry repository with a dummy public images that all my Cloud Run will use at creation with terraform. Then, in a CI/CD pipeline, I will upload them but I can't find a simple way to do it (upload a dummy public image to my artifact registry) using Terraform for now.
<p>There is the code to create to create a Cloud Run with an image from an Artifact Registry repository from the <a href="https://registry.terraform.io/provi...s/data-sources/artifact_registry_docker_image" rel="nofollow noreferrer">Terraform documentation</a>.</p>
<pre class="lang-golang prettyprint-override"><code>
resource "google_artifact_registry_repository" "my_repo" {
location = "us-west1"
repository_id = "my-repository"
format = "DOCKER"
}

data "google_artifact_registry_docker_image" "my_image" {
repository = google_artifact_registry_repository.my_repo.id
image = "my-image"
tag = "my-tag"
}

resource "google_cloud_run_v2_service" "default" {
# ...

template {
containers {
image = data.google_artifact_registry_docker_image.my_image.self_link
}
}
}
</code></pre>
<p>Here is the code to create a Cloud Run from a public image in GCP using Terraform from the <a href="https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_run_v2_service" rel="nofollow noreferrer">Terraform documentation</a>.</p>
<pre class="lang-golang prettyprint-override"><code>resource "google_cloud_run_v2_service" "default" {
name = "cloudrun-service"
location = "us-central1"
ingress = "INGRESS_TRAFFIC_ALL"

template {
containers {
image = "us-docker.pkg.dev/cloudrun/container/hello"
}
}
}
</code></pre>
<p>But how to I upload a (dummy) public image to my Artifact registry to make my Cloud Run use it ?</p>
<p>More context:</p>
<p>I'd like to create an Artifact registry repository with a dummy public images that all my Cloud Run will use at creation with terraform. Then, in a CI/CD pipeline, I will upload them but I can't find a simple way to do it (upload a dummy public image to my artifact registry) using Terraform for now.</p>
Continue reading...
 

Latest posts

Top