Add subdirectory for Git context#531
Conversation
| let args: Array<string> = ['buildx']; | ||
| args.push.apply(args, await getBuildArgs(inputs, defaultContext, buildxVersion)); | ||
| args.push.apply(args, await getCommonArgs(inputs, buildxVersion)); | ||
| if (inputs.context.startsWith('{{defaultContext}}') && buildx.satisfies(buildxVersion, '>=0.7.0')) { |
There was a problem hiding this comment.
Should I add any type of error-handling here?
As it stands, if the version is <0.7.0 it's going to set the context to (literal) {{defaultContext}}:docker.
There was a problem hiding this comment.
I don't think we have to check buildx version here.
There was a problem hiding this comment.
Because the version of build-push-action is tied to the BuildX version?
There was a problem hiding this comment.
No because it only affects buildkit not buildx. Also we need to vendor buildkit on moby moby/moby#42968 otherwise it will not work with the docker driver.
8f6d7e3 to
3dbe9f9
Compare
|
Locally, => ERROR [build-validate build-validate 1/1] RUN --mount=type=bind,target=.,rw <<EOT (set -e...) 0.5s
------
> [build-validate build-validate 1/1] RUN --mount=type=bind,target=.,rw <<EOT (set -e...):
#25 0.383 ERROR: Build result differs. Please build first with "docker buildx bake build"
#25 0.390 M dist/index.js
------
error: failed to solve: executor failed running [/bin/sh -c set -e
git add -A
cp -rf /out/* .
if [ -n "$(git status --porcelain -- dist)" ]; then
echo >&2 'ERROR: Build result differs. Please build first with "docker buildx bake build"'
git status --porcelain -- dist
exit 1
fi
]: exit code: 1
|
3dbe9f9 to
bc719c4
Compare
| args.push.apply(args, await getBuildArgs(inputs, defaultContext, buildxVersion)); | ||
| args.push.apply(args, await getCommonArgs(inputs, buildxVersion)); | ||
| if (inputs.context.startsWith('{{defaultContext}}') && buildx.satisfies(buildxVersion, '>=0.7.0')) { | ||
| inputs.context = inputs.context.replace('{{defaultContext}}', defaultContext); |
There was a problem hiding this comment.
I think it would be better to use handlebars template like it was done in our metadata action.
64af63c to
6cd5c4d
Compare
| done directly by buildkit. The git reference will be based on the [event that triggered your workflow](https://docs.github.com/en/actions/reference/events-that-trigger-workflows) | ||
| and will result in the following context: `https://github.com/<owner>/<repo>.git#<ref>`. | ||
|
|
||
| Beginning with BuildKit version `v0.9.0` ([Buildx](https://github.com/docker/buildx) `v0.7.0`) you can provide a subdirectory to the [Git context](#git-context) by using the magic variable `{{defaultContext}}`: |
There was a problem hiding this comment.
Should I replace magic variable with handlebar template?
There was a problem hiding this comment.
Yes you can write smth like https://github.com/docker/metadata-action#global-expressions
Since v0.9.0 of BuildKit (BuildX v0.7.0) you can provide a subdirectory to the default Git context. Closes docker#460 Closes docker#528 Signed-off-by: Jim Brännlund <jimbrannlund@fastmail.com>
16858fe to
fc5a732
Compare
Since v0.9.0 of BuildKit (BuildX v0.7.0) you can provide a subdirectory
to the default Git context.
Closes #460
Closes #528