Skip to content

Commit

Permalink
fix: handle DOS-style path for Dockerfile in minikube build
Browse files Browse the repository at this point in the history
  • Loading branch information
ComradeProgrammer committed Jun 7, 2023
1 parent aca5f29 commit 9b342d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cmd/minikube/cmd/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/image"
"k8s.io/minikube/pkg/minikube/machine"
"k8s.io/minikube/pkg/minikube/out"
"k8s.io/minikube/pkg/minikube/reason"
docker "k8s.io/minikube/third_party/go-dockerclient"
)
Expand Down Expand Up @@ -310,6 +311,12 @@ var buildImageCmd = &cobra.Command{
// Otherwise, assume it's a tar
}
}
if runtime.GOOS == "windows" && strings.Contains(dockerFile, "\\") {
// if dockerFile is a DOS path, and user did not explicitly forbid this conversion, translate it into UNIX path
// because we are going to build this image in UNIX environment
out.String("minikube detects that you are using DOS-style path %s. minikube will convert it to UNIX-style by replacing all \\ to /", dockerFile)
dockerFile = strings.ReplaceAll(dockerFile, "\\", "/")
}
if err := machine.BuildImage(img, dockerFile, tag, push, buildEnv, buildOpt, []*config.Profile{profile}, allNodes, nodeName); err != nil {
exit.Error(reason.GuestImageBuild, "Failed to build image", err)
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/functional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func validateImageCommands(ctx context.Context, t *testing.T, profile string) {
// docs: Make sure image building works by `minikube image build`
t.Run("ImageBuild", func(t *testing.T) {
MaybeParallel(t)

if _, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pgrep", "buildkitd")); err == nil {
t.Errorf("buildkitd process is running, should not be running until `minikube image build` is ran")
}
Expand Down

0 comments on commit 9b342d2

Please sign in to comment.