GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — command(bake): Specify local and remote bake files by c-ameron · Pull Request #1838 · docker/buildx

Conversation

@c-ameron

@c-ameron c-ameron commented May 24, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

As I mentioned on Slack. This adds the ability to source additional local build definition files when sourcing Bake files via a remote url.
Prefixing a file with cwd:// will source the bake file from the local machine, instead of the remote location.
Local files will be read/have precedence before remote files.

Usage:

docker buildx bake https://github.com/example/upstream.git --file cwd://docker-bake.override.hcl --print

This will source a default file from the example/upstream repository, and also source a build definition from the local machine.

I'm a Go novice so any suggestions are welcome 😄

Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nazar-mambetov, benedikt-bartscher, and alekgosk reacted with thumbs up emoji
All reactions
  • 👍 3 reactions
tonistiigi
tonistiigi reviewed May 25, 2023
View reviewed changes

@tonistiigi tonistiigi left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The "local://" prefix is not ideal but don't have better ideas either.

Ideally, this could have an integration test under tests but let us know if you need help with that.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread commands/bake.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread commands/bake.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@jedevc

jedevc commented May 25, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Fun tangent: was looking into this PR, only to discover that BAKE_CMD_CONTEXT doesn't work correctly anymore: #1840.

The "local://" prefix is not ideal but don't have better ideas either.

This seems kinda similar to the BAKE_CMD_CONTEXT var actually. Internally, we have this work by doing cwd:// - we could re-use this instead of local:// which should also let us share some code?

Ideally, this could have an integration test under tests but let us know if you need help with that.

👍 yup! Our integration tests are quite new here, so any help you can give to help us build those out is very appreciated ❤️

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tonistiigi
tonistiigi previously requested changes Jun 20, 2023
View reviewed changes

@tonistiigi tonistiigi left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

^ PTAL comment from @jedevc

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@c-ameron

c-ameron commented Jun 21, 2023

Copy link
Copy Markdown
Contributor Author

Apologies for the late reply, I was away on holiday so will get back to this PR at the end of the week.

Our integration tests are quite new here, so any help you can give to help us build those out is very appreciated

Could you please point me in the right direction where to do this? I should do it like the TestReadLocalFilesDefault function right?

This seems kinda similar to the BAKE_CMD_CONTEXT var actually. Internally, we have this work by doing cwd:// - we could re-use this instead of local:// which should also let us share some code?

Ok thanks - so I should use the cwd:// prefix instead? I had a look through toBuildOpt but I don't see any reusable methods?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jedevc jedevc mentioned this pull request Jun 27, 2023
tests: add simple local bake test #1916
Merged
@jedevc

jedevc commented Jun 27, 2023

Copy link
Copy Markdown
Collaborator

Could you please point me in the right direction where to do this? I should do it like the TestReadLocalFilesDefault function right?

We have our integration tests in https://github.com/docker/buildx/blob/master/tests/bake.go, and our bake unit tests in https://github.com/docker/buildx/blob/master/bake/bake_test.go. Ideally - we'd be able to have both, though if the logic is only defined in the commands package, we can't have a unit test under our current structure really (which is absolutely fine).

Ok thanks - so I should use the cwd:// prefix instead? I had a look through toBuildOpt but I don't see any reusable methods?

Yeah, cwd:// would be preferable I think, just so we don't end up having multiple different prefixes for the same thing, referencing local directories.

It's fine if the code doesn't share nicely, this is for different purposes 🎉 Maybe it would be good to try and define the cwd:// constant somewhere though, so at least when manipulating the strings we're using common code (having different code for manipulating URLs has gotten us before 😢).

c-ameron reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@c-ameron
c-ameron force-pushed the feat/local-remote-files branch from 99761bf to c84b21d Compare July 7, 2023 21:43
jedevc
jedevc reviewed Jul 26, 2023
View reviewed changes
Comment thread commands/bake.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@jedevc

jedevc commented Jul 26, 2023

Copy link
Copy Markdown
Collaborator

Also, can you squash commits, and add a sign-off (see https://github.com/docker/buildx/blob/master/.github/CONTRIBUTING.md#sign-your-work)

c-ameron reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@c-ameron
c-ameron force-pushed the feat/local-remote-files branch 2 times, most recently from 9034439 to 5638919 Compare August 12, 2023 15:42
@c-ameron

c-ameron commented Aug 12, 2023

Copy link
Copy Markdown
Contributor Author

Hi, apologies for the delay in getting this done. I've added an integration test as well. Let me know if you require anything else. Thanks for your time 😃

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@c-ameron
c-ameron requested a review from jedevc August 12, 2023 15:46
@jedevc
jedevc dismissed tonistiigi’s stale review August 13, 2023 13:22

Comments were addressed

jedevc
jedevc approved these changes Aug 13, 2023
View reviewed changes
@jedevc jedevc added status/merge and removed status/merge labels Aug 13, 2023
@jedevc
jedevc force-pushed the feat/local-remote-files branch from 5638919 to 78616f2 Compare August 13, 2023 15:35
@jedevc

jedevc commented Aug 13, 2023

Copy link
Copy Markdown
Collaborator

@c-ameron I realized that 5638919#diff-3f9c21dce82a82fae6d5ca096e77e5ddcf0eccd7051f815b452ec26fbfeb314bR284 was incorrect, which was causing the e2e tests to fail.

I pushed a commit that should fix that up, and simplifies the splitting logic, so we don't need the isRemote argument - hopefully looks good to you.

c-ameron reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jedevc
jedevc requested a review from tonistiigi August 13, 2023 15:37
@c-ameron

c-ameron commented Aug 14, 2023

Copy link
Copy Markdown
Contributor Author

Cool! Thanks for your help @jedevc ! 😃

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@c-ameron

c-ameron commented Sep 7, 2023

Copy link
Copy Markdown
Contributor Author

Is this ok to be approved/merged @tonistiigi ? Thanks in advance! 😃

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@c-ameron
c-ameron force-pushed the feat/local-remote-files branch 4 times, most recently from 78616f2 to 6d13818 Compare October 4, 2023 16:21
@c-ameron

c-ameron commented Oct 4, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I've rebased the commit onto master as there was a conflict in commands/bake.go :)

Although I'm not sure why this test is now failing https://github.com/docker/buildx/actions/runs/6408757454/job/17398732309?pr=1838

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@crazy-max crazy-max added area/bake status/needs-docs-follow-up labels Oct 21, 2023
@crazy-max
crazy-max force-pushed the feat/local-remote-files branch from 6d13818 to d551dd1 Compare October 21, 2023 06:39
@crazy-max

crazy-max commented Oct 21, 2023

Copy link
Copy Markdown
Member

Although I'm not sure why this test is now failing https://github.com/docker/buildx/actions/runs/6408757454/job/17398732309?pr=1838

@c-ameron Sorry for the delay. I have rebased to fix this ci issue.

I pushed an extra commit to fix some error handling when reading local/remote files and consolidate the logic in a single func as well. Feel free to squash if that looks good to you.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@c-ameron
c-ameron force-pushed the feat/local-remote-files branch 2 times, most recently from 9bd369d to 589a4c9 Compare October 23, 2023 13:52
@c-ameron

c-ameron commented Oct 23, 2023

Copy link
Copy Markdown
Contributor Author

No worries, thanks @crazy-max . I've squashed and added you as a co-author too.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@crazy-max
crazy-max force-pushed the feat/local-remote-files branch 3 times, most recently from 208b042 to 38b0bc0 Compare October 24, 2023 17:35
@c-ameron @crazy-max
command(bake): Specify local and remote bake files
abfc04f
This adds the ability to source additional local build definition files when
sourcing Bake files via a remote url.
Prefixing a file with 'cwd://' will source a bake file on the local
machine, instead of the remote location.
Local files will be read/have precedence before remote files.

Usage:
```
docker buildx bake https://github.com/example/upstream.git --file cwd://docker-bake.override.hcl --print
```
This will source a default file from the example/upstream repository,
and also source a build definition from the local machine.

Also moves remote and local files reading logic to a func

Signed-off-by: CrazyMax <[email protected]>
Signed-off-by: Cameron Adams <[email protected]>
Co-authored-by: CrazyMax <[email protected]>
@crazy-max
crazy-max force-pushed the feat/local-remote-files branch from 38b0bc0 to abfc04f Compare October 24, 2023 17:37
@crazy-max crazy-max added this to the v0.12.0 milestone Oct 30, 2023
@crazy-max
crazy-max merged commit 639e0bc into docker:master Nov 2, 2023
@crazy-max crazy-max mentioned this pull request Nov 17, 2023
build(bake): specify local and remote bake definitions docker/docs#18711
Merged
@crazy-max crazy-max removed the status/needs-docs-follow-up label Nov 17, 2023
@crazy-max crazy-max mentioned this pull request Dec 21, 2023
git context support docker/bake-action#181
Merged
This was referenced Feb 1, 2024
inconsistent bake files merge order #2236
Closed
bake: fix definitions merge order #2237
Merged
@crazy-max crazy-max mentioned this pull request Mar 28, 2024
bake: git auth support for remote definitions #2363
Merged
@crazy-max crazy-max added status/needs-docs-follow-up and removed status/needs-docs-follow-up labels Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jedevc jedevc jedevc approved these changes
@tonistiigi tonistiigi Awaiting requested review from tonistiigi

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

area/bake

Projects

None yet

Milestone

v0.12.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@c-ameron @jedevc @crazy-max @tonistiigi
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.