diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index e276c8e72557..085ccb2aa553 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -63,6 +63,9 @@ jobs: archutil-arm64: runs-on: ubuntu-22.04 + # TODO: enable when binutils-loongarch64-linux-gnu pkg is available for aarch64 arch + # https://github.com/moby/buildkit/pull/4392#issuecomment-1938223235 + if: false steps: - name: Checkout diff --git a/docs/windows.md b/docs/windows.md index 14cc882ee17d..9f8e69a9b85e 100644 --- a/docs/windows.md +++ b/docs/windows.md @@ -89,6 +89,7 @@ Now that everything is setup, let's build a [simple _hello world_ image](https:/ ```powershell Set-Content Dockerfile @" FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + USER ContainerAdministrator COPY hello.txt C:/ RUN echo "Goodbye!" >> hello.txt CMD ["cmd", "/C", "type C:\\hello.txt"] diff --git a/frontend/dockerfile/dockerfile2llb/convert.go b/frontend/dockerfile/dockerfile2llb/convert.go index 531aa09484bd..b79407955542 100644 --- a/frontend/dockerfile/dockerfile2llb/convert.go +++ b/frontend/dockerfile/dockerfile2llb/convert.go @@ -1252,18 +1252,30 @@ func dispatchCopy(d *dispatchState, cfg copyConfig) error { a = a.Copy(st, f, dest, opts...) } } else { + var patterns []string + if cfg.parents { + // detect optional pivot point + parent, pattern, ok := strings.Cut(src, "/./") + if !ok { + pattern = src + src = "/" + } else { + src = parent + } + + pattern, err = system.NormalizePath("/", pattern, d.platform.OS, false) + if err != nil { + return errors.Wrap(err, "removing drive letter") + } + + patterns = []string{strings.TrimPrefix(pattern, "/")} + } + src, err = system.NormalizePath("/", src, d.platform.OS, false) if err != nil { return errors.Wrap(err, "removing drive letter") } - var patterns []string - if cfg.parents { - path := strings.TrimPrefix(src, "/") - patterns = []string{path} - src = "/" - } - opts := append([]llb.CopyOption{&llb.CopyInfo{ Mode: mode, FollowSymlinks: true, diff --git a/frontend/dockerfile/dockerfile_parents_test.go b/frontend/dockerfile/dockerfile_parents_test.go index 4400a27781eb..47f06e803924 100644 --- a/frontend/dockerfile/dockerfile_parents_test.go +++ b/frontend/dockerfile/dockerfile_parents_test.go @@ -18,6 +18,7 @@ import ( var parentsTests = integration.TestFuncs( testCopyParents, + testCopyRelativeParents, ) func init() { @@ -75,3 +76,108 @@ COPY --parents foo1/foo2/ba* . require.NoError(t, err) require.Equal(t, "testing2", string(dt)) } + +func testCopyRelativeParents(t *testing.T, sb integration.Sandbox) { + f := getFrontend(t, sb) + + dockerfile := []byte(` +FROM alpine AS base +WORKDIR /test +RUN <