-
-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add example of building a Dockerfile with local tar file build context #702
base: main
Are you sure you want to change the base?
Conversation
We have https://github.com/bazel-contrib/rules_oci/tree/main/examples/dockerfile, how is this different than that one? |
That example does not show how to use the output of other Bazel targets as input to the Dockerfile build |
Than can we change it so it does? i don't see the difference between this example and the other one, other than putting the srcs into a tar file beforehand so you don't have to deal with paths that start with |
Yes, happy to do this. The reason I made a new example is that it's a little more complicated than the existing example, so might hinder understanding. What do you think? |
We can add some comments explaining why there is two different buildx targets in the same package and the difference. |
I have merged the two examples |
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.
thanks!
examples/dockerfile/BUILD.bazel
Outdated
# This tar can be arranged in arbitrary ways. | ||
# For example, one could grab pkg_files from elsewhere in the workspace. | ||
# Anything in the tar can be used by a Dockerfile ADD or COPY. | ||
pkg_tar( |
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.
actually can we not use pkg_tar here? we have bazel-lib dependency here already. you can use https://github.com/bazel-contrib/bazel-lib/blob/main/docs/tar.md
(i don't want a pkg_tar dependency even if it's dev_dep)
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.
I might need some assistance with this one.
When I try bazel build //examples/dockerfile:buildx_context
I get:
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
Target //examples/dockerfile:buildx_context failed to build
Any ideas?
There are some failures, can you take a look? |
…r/rules_oci into example-dockerfile-elaborate
This PR adds an example of using a Dockerfile with a local tar as a build context.
This is not the ideal approach, which this is clearly signposted in the README!, but it shows an easy migration path from
rules_docker
. The existing example does not show how Bazel build artefacts can be passed to BuildX.How it works:
rules_pkg
sh_binary
andrun_binary
oci_image
This is a replacement for
container_run_and_commit
.The example could easily be adapted to behave like
container_run_and_extract
by changing the--output
flag to atar
.