Krzysztof Mazur
Krzysztof Mazur

Reputation: 608

GCP Dockerfile using Artifact Registry

I have a question.

What's the best approach to building a Docker image using the pip artifact from the Artifact Registry?

I have a Cloud Build build that runs a Docker build, the only Dockerfile is pip install -r requirements.txt, one of the dependencies of which is the library located in the Artifact Registry.

When executing a stage with the image gcr.io / cloud-builders / docker, I get the error that my Artifact Registry is not accessible, which is quite logical. I have access only from the image performing the given step, not from the image that is being built in this step.

Any ideas?

Edit:

For now I will use Secret Manager to pass JSON key to my Dockerfile, but hope for better solution.

Upvotes: 1

Views: 1444

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75745

When you use Cloud Build, you can forward the metadata server access through the Docker build process. It's documented, but absolutely not clear (personally, the first time I made a mail to Cloud Build PM to ask him, and he send me the documentation link.)

Now, your docker build can access the metadata server and be authenticated with the Cloud Build runtime service account. It should make your process easiest.

Upvotes: 3

Related Questions