How can I properly configure a gcloud account for my Gradle Docker plugin when using GCR?

8/15/2017

Our containers are hosted using Google Container Registry, and I am using id "com.bmuschko.docker-java-application" version "3.0.7" to build and deploy docker containers. However, I run into permission issues whenever I try to pull the base image or push the image to GCR (I am able to get to the latter step by pulling the image and having it available locally).

I'm a little bit confused by how I can properly configure a particular GCloud account to be used whenever issuing any Docker related calls over a wire using the plugin.

As a first attempt, I've tried to create a task that precedes and build or push commands:

task gcloudLogin(type:Exec) {
  executable "gcloud"
  args "auth", "activate-service-account", "--key-file", "$System.env.KEY_FILE"
}

However, this simple wrapper doesn't work as desired. Is there currently a supported way to have this plugin work with GCR?

-- mike
google-kubernetes-engine
gradle

1 Answer

8/17/2017

Got in touch with the maintainers of the gradle docker plugin and we have found this to be a valid solution.

-- mike
Source: StackOverflow