Skip to content

Enable ssh forwarding when building a remote target#3050

Merged
thaJeztah merged 1 commit intodocker:masterfrom
alexcb:enable-ssh-when-accessing-git-url
Aug 19, 2021
Merged

Enable ssh forwarding when building a remote target#3050
thaJeztah merged 1 commit intodocker:masterfrom
alexcb:enable-ssh-when-accessing-git-url

Conversation

@alexcb
Copy link
Copy Markdown

@alexcb alexcb commented Apr 13, 2021

this fixes moby/buildkit#2040 by enabling ssh forwarding when a remote address is given on the command line, this is a similar fix to docker/buildx#581

previously when I ran:

DOCKER_BUILDKIT=1 ./build/docker -D build -t testing git@github.ent.corp:organization/testrepository.git

I could replicate the issue and would get this error:

failed to solve with frontend dockerfile.v0: failed to read dockerfile: failed to load cache key: rpc error: code = Unimplemented desc = unknown service moby.sshforward.v1.SSH

However now with this fix, I get a much more appropriate error showing that my git clone failed:

 => ERROR [internal] load git source git@github.ent.corp:organization/testrepository.git                                                                                                                                                                                0.1s
------                                                                                                                                                                                                                                                                       
 > [internal] load git source git@github.ent.corp:organization/testrepository.git:
#1 0.105 ssh: Could not resolve hostname github.ent.corp: Name or service not known
#1 0.106 fatal: Could not read from remote repository.
#1 0.106 
#1 0.106 Please make sure you have the correct access rights
#1 0.106 and the repository exists.

and when I point it at an actual private repo, it can authenticate and builds as expected.

$ DOCKER_BUILDKIT=1 ./build/docker -D build -t testing 'git@github.com:alexcb/private-repo-with-dockerfile.git#main'
DEBU[0000] serving grpc connection                      
[+] Building 2.6s (5/5) FINISHED                                                                                                                                                                                                                                             
 => [internal] load git source git@github.com:alexcb/private-repo-with-dockerfile.git#main                                                                                                                                                                              1.3s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                                                                                                                                                        0.0s
 => CACHED [1/2] FROM docker.io/library/alpine:latest                                                                                                                                                                                                                   0.0s 
 => [2/2] RUN echo hello private world                                                                                                                                                                                                                                  1.2s 
 => exporting to image                                                                                                                                                                                                                                                  0.0s 
 => => exporting layers                                                                                                                                                                                                                                                 0.0s 
 => => writing image sha256:4fad0d52c1e9a24e4ce4710b589bd94636c52ce8e275461e963ec81a1fe7d8b6                                                                                                                                                                            0.0s 
 => => naming to docker.io/library/testing  

Comment thread vendor.conf Outdated
@thaJeztah
Copy link
Copy Markdown
Member

@tonistiigi @crazy-max ptal

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 20, 2021

Codecov Report

Merging #3050 (af1bb80) into master (e3dfc24) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #3050      +/-   ##
==========================================
- Coverage   57.99%   57.98%   -0.02%     
==========================================
  Files         302      302              
  Lines       21748    21754       +6     
==========================================
  Hits        12613    12613              
- Misses       8212     8218       +6     
  Partials      923      923              

@tonistiigi
Copy link
Copy Markdown
Member

@alexcb Validation + DCO broken

@alexcb
Copy link
Copy Markdown
Author

alexcb commented Apr 21, 2021

It looks like the buildkit dependency version change that @thaJeztah and I made yesterday broke it #3050 (comment)

I suspect we'll need to update the 0.8 branch in the end (to include my PRs up until d3e0a6f2d8c36dcd2d785ab436ead8bd2dc50f28) to make this PR work.

Should I open another PR against https://github.com/moby/buildkit/tree/v0.8 with the required cherry-picks to make this work?

@tonistiigi
Copy link
Copy Markdown
Member

If you need something from master branch that isn't in v0.8 (and isn't a regression bugfix that should be picked anyway) then just vendor from the commit you need.

@alexcb
Copy link
Copy Markdown
Author

alexcb commented Apr 21, 2021

If you need something from master branch that isn't in v0.8 (and isn't a regression bugfix that should be picked anyway) then just vendor from the commit you need.

Does this mean I can re-enable my change to vendor.conf, to set it back to what I initially had it set to: github.com/moby/buildkit d3e0a6f2d8c36dcd2d785ab436ead8bd2dc50f28 # needed for util/gitutils?

@tonistiigi
Copy link
Copy Markdown
Member

Yes, @thaJeztah said that the commits you needed should have already been in the release tag. If this is not true then vendor the commit you need.

@alexcb alexcb force-pushed the enable-ssh-when-accessing-git-url branch 3 times, most recently from c551a1e to f4e935f Compare April 21, 2021 18:42
@alexcb
Copy link
Copy Markdown
Author

alexcb commented Apr 21, 2021

thanks for the help @tonistiigi , I rebased this PR off master and the tests are once again passing.

@alexcb alexcb requested a review from tonistiigi May 4, 2021 16:14
@avroshk
Copy link
Copy Markdown

avroshk commented Jun 25, 2021

Would love to get this merged @alexcb!
Please let me know if I can help resolve the conflicts.

@felipematheus
Copy link
Copy Markdown

felipematheus commented Aug 19, 2021

I'm looking forward for this fix to be merged, would solve a problem with one of my builds.

- this fixes moby/buildkit#2040 by enabling
ssh forwarding when a remote address is given on the command line, this
is a similar fix to docker/buildx#581

Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
@alexcb alexcb force-pushed the enable-ssh-when-accessing-git-url branch from f4e935f to af1bb80 Compare August 19, 2021 16:04
@alexcb alexcb requested a review from thaJeztah August 19, 2021 17:52
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build fails with "unknown service moby.sshforward.v1.SSH"

6 participants