From 854a5422350a62c09e3e83362d031b6ccb4c1739 Mon Sep 17 00:00:00 2001
From: zrc <1259609102@qq.com>
Date: Tue, 14 Dec 2021 16:32:53 +0800
Subject: [PATCH] [fix] Specify the dockerfile path when building under
windows, the remote docker service does not recognize windows separator
---
.../main/java/com/spotify/plugin/dockerfile/BuildMojo.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/plugin/src/main/java/com/spotify/plugin/dockerfile/BuildMojo.java b/plugin/src/main/java/com/spotify/plugin/dockerfile/BuildMojo.java
index 248fa270..8c0ce869 100644
--- a/plugin/src/main/java/com/spotify/plugin/dockerfile/BuildMojo.java
+++ b/plugin/src/main/java/com/spotify/plugin/dockerfile/BuildMojo.java
@@ -38,6 +38,8 @@
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+
+import org.apache.commons.io.FilenameUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
@@ -70,6 +72,7 @@ public class BuildMojo extends AbstractDockerMojo {
@Parameter(property = "dockerfile.dockerfile", required = false)
private File dockerfile;
+
/**
* The repository to put the built image into when building the Dockerfile, for example
* spotify/foo. You should also set the tag parameter, otherwise the tag
@@ -179,8 +182,8 @@ static String buildImage(@Nonnull DockerClient dockerClient,
final ArrayList buildParameters = new ArrayList<>();
if (dockerfile != null) {
- buildParameters.add(DockerClient.BuildParam.dockerfile(
- contextDirectory.relativize(dockerfile)));
+ buildParameters.add(new DockerClient.BuildParam("dockerfile",
+ FilenameUtils.separatorsToUnix(contextDirectory.relativize(dockerfile).toString())));
}
final LoggingProgressHandler progressHandler = new LoggingProgressHandler(log, verbose);