Skip to content

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
jedevc added 2 commits April 12, 2023 12:11
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 force-pushed the more-ssh-context-fixes branch from e7356d9 to 566f41b Compare April 12, 2023 11:11
@jedevc jedevc merged commit b716e48 into docker:master Apr 14, 2023
@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.

2 participants