-
-
Notifications
You must be signed in to change notification settings - Fork 165
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!
There are some failures, can you take a look? |
…r/rules_oci into example-dockerfile-elaborate
examples/dockerfile/BUILD.bazel
Outdated
name = "buildx_context_tree_prefixed", | ||
mtree = ":buildx_context_tree", | ||
strip_prefix = package_name(), | ||
package_dir = "/app", |
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.
you need a ./app
to fix the issue.
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 - this works
One thing I found a little surprising is that I need to add the srcs
for both the mtree_spec
and the tar
.
Is this expected? Am I using it correctly?
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
.