Signed-off-by: John Howard <jhoward@microsoft.com>
Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
| ... | ... |
@@ -307,6 +307,12 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
| 307 | 307 |
return nil |
| 308 | 308 |
} |
| 309 | 309 |
|
| 310 |
+// isUNC returns true if the path is UNC (one starting \\). It always returns |
|
| 311 |
+// false on Linux. |
|
| 312 |
+func isUNC(path string) bool {
|
|
| 313 |
+ return runtime.GOOS == "windows" && strings.HasPrefix(path, `\\`) |
|
| 314 |
+} |
|
| 315 |
+ |
|
| 310 | 316 |
// getDockerfileRelPath uses the given context directory for a `docker build` |
| 311 | 317 |
// and returns the absolute path to the context directory, the relative path of |
| 312 | 318 |
// the dockerfile in that context directory, and a non-nil error on success. |
| ... | ... |
@@ -317,9 +323,16 @@ func getDockerfileRelPath(givenContextDir, givenDockerfile string) (absContextDi |
| 317 | 317 |
|
| 318 | 318 |
// The context dir might be a symbolic link, so follow it to the actual |
| 319 | 319 |
// target directory. |
| 320 |
- absContextDir, err = filepath.EvalSymlinks(absContextDir) |
|
| 321 |
- if err != nil {
|
|
| 322 |
- return "", "", fmt.Errorf("unable to evaluate symlinks in context path: %v", err)
|
|
| 320 |
+ // |
|
| 321 |
+ // FIXME. We use isUNC (always false on non-Windows platforms) to workaround |
|
| 322 |
+ // an issue in golang. On Windows, EvalSymLinks does not work on UNC file |
|
| 323 |
+ // paths (those starting with \\). This hack means that when using links |
|
| 324 |
+ // on UNC paths, they will not be followed. |
|
| 325 |
+ if !isUNC(absContextDir) {
|
|
| 326 |
+ absContextDir, err = filepath.EvalSymlinks(absContextDir) |
|
| 327 |
+ if err != nil {
|
|
| 328 |
+ return "", "", fmt.Errorf("unable to evaluate symlinks in context path: %v", err)
|
|
| 329 |
+ } |
|
| 323 | 330 |
} |
| 324 | 331 |
|
| 325 | 332 |
stat, err := os.Lstat(absContextDir) |
| ... | ... |
@@ -354,9 +367,16 @@ func getDockerfileRelPath(givenContextDir, givenDockerfile string) (absContextDi |
| 354 | 354 |
} |
| 355 | 355 |
|
| 356 | 356 |
// Evaluate symlinks in the path to the Dockerfile too. |
| 357 |
- absDockerfile, err = filepath.EvalSymlinks(absDockerfile) |
|
| 358 |
- if err != nil {
|
|
| 359 |
- return "", "", fmt.Errorf("unable to evaluate symlinks in Dockerfile path: %v", err)
|
|
| 357 |
+ // |
|
| 358 |
+ // FIXME. We use isUNC (always false on non-Windows platforms) to workaround |
|
| 359 |
+ // an issue in golang. On Windows, EvalSymLinks does not work on UNC file |
|
| 360 |
+ // paths (those starting with \\). This hack means that when using links |
|
| 361 |
+ // on UNC paths, they will not be followed. |
|
| 362 |
+ if !isUNC(absDockerfile) {
|
|
| 363 |
+ absDockerfile, err = filepath.EvalSymlinks(absDockerfile) |
|
| 364 |
+ if err != nil {
|
|
| 365 |
+ return "", "", fmt.Errorf("unable to evaluate symlinks in Dockerfile path: %v", err)
|
|
| 366 |
+ } |
|
| 360 | 367 |
} |
| 361 | 368 |
|
| 362 | 369 |
if _, err := os.Lstat(absDockerfile); err != nil {
|