πŸ’₯ TRENDING: Docker/buildx/issues/ - Full Archive

Skip to content

Conversation

@tonistiigi

fix #641

Allows accessing the main context for bake command from bake
file that has been imported remotely.

# docker buildx bake "git://github.com/docker/cli" --print
{
  "target": {
    "binary": {
      "context": "git:/github.com/docker/cli",
      "dockerfile": "Dockerfile",
      "args": {
        "BASE_VARIANT": "alpine",
        "GO_STRIP": "",
        "VERSION": ""
      },
      "target": "binary",
      "platforms": [
        "local"
      ],
      "output": [
        "build"
      ]
    }
  }
}

/tmp/a # touch foo bar
/tmp/a # docker buildx bake "git://github.com/tonistiigi/buildx#remote-test"
...
 > [4/4] RUN ls -l && stop:
#9 0.207 total 0
#9 0.207 -rw-r--r--    1 root     root             0 Jul 13 03:39 bar
#9 0.207 -rw-r--r--    1 root     root             0 Jul 13 03:39 foo
#9 0.207 /bin/sh: stop: not found


 # docker buildx bake "git://github.com/tonistiigi/buildx#remote-test" "git://github.com/docker/cli"
...
#8 0.232 -rw-r--r--    1 root     root          1893 Jul 13 03:58 poule.yml
#8 0.232 drwxr-xr-x    7 root     root          4096 Jul 13 03:58 scripts
#8 0.232 drwxr-xr-x    3 root     root          4096 Jul 13 03:58 service
#8 0.232 drwxr-xr-x    2 root     root          4096 Jul 13 03:58 templates
#8 0.232 drwxr-xr-x   11 root     root          4096 Jul 13 03:58 vendor
#8 0.232 -rwxr-xr-x    1 root     root         10123 Jul 13 03:58 vendor.conf
#8 0.232 /bin/sh: stop: not found

#   docker buildx bake "git://github.com/tonistiigi/buildx#remote-test" "https://ftp.gnu.org/gnu/binutils/binutils-2.36.tar.gz"
...
 > [4/4] RUN ls -l && stop:
#8 0.250 total 4
#8 0.251 drwxrwxrwx   19 root     root          4096 Jul 13 04:00 binutils-2.36
#8 0.251 /bin/sh: stop: not found

Signed-off-by: Tonis Tiigi [email protected]

Allows accessing the main context for bake command from bake
file that has been imported remotely.

Signed-off-by: Tonis Tiigi <[email protected]>
@tonistiigi tonistiigi requested a review from crazy-max July 13, 2021 04:02
@tonistiigi

This also fixed the issue where remote URLs were used in bake targets. Previously the values always passed path.Clean that corrupted the url.

crazy-max

Choose a reason for hiding this comment

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

@tonistiigi LGTM. In a follow-up, we could reserve variables starting with BAKE_ as we discussed.

@tonistiigi tonistiigi merged commit 6e3a319 into docker:master Jul 13, 2021
crazy-max
t.ContextPath = inp.URL
return
}
if strings.HasPrefix(t.ContextPath, "cwd://") {

Choose a reason for hiding this comment

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

Document cwd protocol

Choose a reason for hiding this comment

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

I'm not sure if it is a good idea. I don't want users to write it in the bake file. If they do then they break the remote URL case. They should use the variable and this should be the internal behavior of the variable. We should be able to change that to workdir:// for example and no old files should be broken.

We should document the builtin var, and also more docs for vars/attrs in general.

Choose a reason for hiding this comment

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

they break the remote URL

Ah yes right

We should document the builtin var, and also more docs for vars/attrs in general.

πŸ‘

@crazy-max crazy-max mentioned this pull request Jul 27, 2021
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.

bake: local context not supported with remote git bake definition

2 participants