Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various context fixups #1734

Merged
merged 2 commits into from
Apr 14, 2023
Merged

Various context fixups #1734

merged 2 commits into from
Apr 14, 2023

Conversation

jedevc
Copy link
Collaborator

@jedevc jedevc commented Apr 12, 2023

馃悰 More context bug fixes 馃帀

See commit messages for more details.

  1. Fixes resolving the context for remote bake files over SSH:

    $ docker buildx bake git@github.com:docker/buildx.git
    [+] Building 3.8s (2/2) FINISHED                                                                                                                                 docker-container:container
     => CACHED [internal] load git source git@github.com:docker/buildx.git                                                                                                                 3.2s
     => ERROR [internal] load git source git@github.com:docker/buildx.git                                                                                                                  0.0s 
    ------                                                                                                                                                                                      
    > [internal] load git source git@github.com:docker/buildx.git:
    ------
    ERROR: failed to solve: failed to read dockerfile: failed to load cache key: unset ssh forward key default
    

    bake: forward default ssh agent for remote bake file聽#1711 only fixed this for --print, we actually do two loads of the same context: one for bake to read the file, and another for the build to read the contents of the Dockerfile.

  2. Fixes resolving dockerfile URLs for the controller:

    $ docker buildx build -f https://raw.githubusercontent.com/docker/buildx/master/hack/dockerfiles/lint.Dockerfile .
    INFO: connecting to buildx server
    INFO: no buildx server found; launching...
    [+] Building 0.0s (0/0)                                                                                                                                                                     
    ERROR: failed to build: rpc error: code = Unknown desc = could not find /home/jedevc/Documents/Docker/buildx/https:/raw.githubusercontent.com/docker/buildx/master/hack/dockerfiles: stat /home/jedevc/Documents/Docker/buildx/https:/raw.githubusercontent.com/docker/buildx/master/hack/dockerfiles: no such file or directory
    

    build: fixup resolvePaths for remote context path聽#1701 only fixes this for the context path, I wasn't aware that the Dockerfile path is explicitly allowed to be an HTTP URL:

    buildx/build/build.go

    Lines 1314 to 1323 in 672eeed

    if urlutil.IsURL(inp.DockerfilePath) {
    dockerfileDir, err = createTempDockerfileFromURL(ctx, d, inp.DockerfilePath, pw)
    if err != nil {
    return nil, err
    }
    toRemove = append(toRemove, dockerfileDir)
    dockerfileName = "Dockerfile"
    target.FrontendAttrs["dockerfilekey"] = "dockerfile"
    delete(target.FrontendInputs, "dockerfile")
    }

@jedevc jedevc requested a review from crazy-max April 12, 2023 10:52
The updateContext function may make modifications to the build inputs,
creating either an SSH URL, or an SSH llb.State. In these cases, we need
to ensure that we appropriately expose the client's default agent.

Previously, we would only expose it if the remote context was a git URL,
however, we need to also ensure that if the input was used to override
the context (in the case of ReadRemoteFiles), that we expose the agent
here as well.

Signed-off-by: Justin Chadwell <me@jedevc.com>
Dockerfiles can be HTTP URLs as well as local paths 馃う

We just copy the same logic we use for resolving context paths, and
apply it here as well.

Signed-off-by: Justin Chadwell <me@jedevc.com>
@jedevc jedevc merged commit b716e48 into docker:master Apr 14, 2023
54 checks passed
@jedevc jedevc deleted the more-ssh-context-fixes branch April 14, 2023 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants