diff --git a/plugin/pom.xml b/plugin/pom.xml
index cd6101ad..04f2f942 100644
--- a/plugin/pom.xml
+++ b/plugin/pom.xml
@@ -14,12 +14,27 @@
Dockerfile Maven Plugin
Adds support for building Dockerfiles in Maven
+
+
+
+ com.google.code.findbugs
+ jsr305
+ 2.0.1
+
+
+
+
com.spotify
docker-client
shaded
- 4.0.8
+ 8.6.2
+
+
+ com.google.auth
+ google-auth-library-oauth2-http
+ 0.6.0
com.google.guava
diff --git a/plugin/src/main/java/com/spotify/plugin/dockerfile/AbstractDockerMojo.java b/plugin/src/main/java/com/spotify/plugin/dockerfile/AbstractDockerMojo.java
index ccac947d..ba4c4d85 100644
--- a/plugin/src/main/java/com/spotify/plugin/dockerfile/AbstractDockerMojo.java
+++ b/plugin/src/main/java/com/spotify/plugin/dockerfile/AbstractDockerMojo.java
@@ -27,11 +27,14 @@
import com.spotify.docker.client.DockerClient;
import com.spotify.docker.client.exceptions.DockerCertificateException;
+import com.spotify.docker.client.gcr.ContainerRegistryAuthSupplier;
+import com.spotify.docker.client.messages.RegistryAuthSupplier;
import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Objects;
+import java.util.concurrent.ExecutorService;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -378,10 +381,21 @@ protected static String formatImageName(@Nonnull String repository, @Nonnull Str
@Nonnull
protected DockerClient openDockerClient() throws MojoExecutionException {
+ ContainerRegistryAuthSupplier authSupplier = null;
+ try {
+ authSupplier = ContainerRegistryAuthSupplier.forApplicationDefaultCredentials()
+ .build();
+ getLog().info("Using Google application credentials");
+ } catch (IOException ex) {
+ // No GCP default credentials available
+ getLog().debug("Failed to create Google default credentials", ex);
+ }
+
try {
return DefaultDockerClient.fromEnv()
.readTimeoutMillis(readTimeoutMillis)
.connectTimeoutMillis(connectTimeoutMillis)
+ .registryAuthSupplier(authSupplier)
.build();
} catch (DockerCertificateException e) {
throw new MojoExecutionException("Could not load Docker certificates", e);