Documentation on how to build container images on OBS? BuildTags? Labels?
Hi all, I wanted to try out building a distrobox image on OBS. I took Richard's repository as a blueprint:
https://build.opensuse.org/project/show/home:RBrownSUSE:containers
Is there any documentation on how to use the BuildTags and the labels? Especially if the container images are not supposed to end up in the official repos, but should stay in "my" home namespace? My current state is this, which fails. I am not interested in just solving this error, but would like to know what all of these do and how I should set them for a home-spaced image...
# SPDX-License-Identifier: MIT #!BuildTag: opensuse/distrobox-johanneskastl:latest #!BuildTag: opensuse/distrobox-johanneskastl:%%PKG_VERSION%% #!BuildTag: opensuse/distrobox-johanneskastl:%%PKG_VERSION%%.%RELEASE%
FROM opensuse/distrobox:latest LABEL maintainer="Johannes Kastl
" # labelprefix=org.opensuse.distrobox PREFIXEDLABEL org.opencontainers.image.title="Distrobox johanneskastl container" PREFIXEDLABEL org.opencontainers.image.description="Distrobox johanneskastl container" PREFIXEDLABEL org.opencontainers.image.created="%BUILDTIME%" PREFIXEDLABEL org.opencontainers.image.version="%%PKG_VERSION%%.%RELEASE%" PREFIXEDLABEL org.opencontainers.image.vendor="openSUSE Project" PREFIXEDLABEL org.openbuildservice.disturl="%DISTURL%" PREFIXEDLABEL org.opensuse.reference="registry.opensuse.org/opensuse/distrobox-johanneskastl:%%PKG_VERSION%%.%RELEASE%"
Thanks in advance and have a nice day! Kind Regards, Johannes
Hi Johannes,
Johannes Kastl
Hi all,
I wanted to try out building a distrobox image on OBS. I took Richard's repository as a blueprint:
https://build.opensuse.org/project/show/home:RBrownSUSE:containers
Is there any documentation on how to use the BuildTags and the labels?
The only thing that I am aware of is this wiki page: https://en.opensuse.org/Building_derived_containers And then there's my talk from the openSUSE Conference 2023: https://www.youtube.com/watch?v=d9LTLzoJzJE (slides are here: https://github.com/dcermak/building-containers-in-obs)
Especially if the container images are not supposed to end up in the official repos, but should stay in "my" home namespace?
My current state is this, which fails. I am not interested in just solving this error, but would like to know what all of these do and how I should set them for a home-spaced image...
# SPDX-License-Identifier: MIT #!BuildTag: opensuse/distrobox-johanneskastl:latest #!BuildTag: opensuse/distrobox-johanneskastl:%%PKG_VERSION%% #!BuildTag: opensuse/distrobox-johanneskastl:%%PKG_VERSION%%.%RELEASE%
FROM opensuse/distrobox:latest LABEL maintainer="Johannes Kastl
" # labelprefix=org.opensuse.distrobox PREFIXEDLABEL org.opencontainers.image.title="Distrobox johanneskastl container" PREFIXEDLABEL org.opencontainers.image.description="Distrobox johanneskastl container" PREFIXEDLABEL org.opencontainers.image.created="%BUILDTIME%" PREFIXEDLABEL org.opencontainers.image.version="%%PKG_VERSION%%.%RELEASE%" PREFIXEDLABEL org.opencontainers.image.vendor="openSUSE Project" PREFIXEDLABEL org.openbuildservice.disturl="%DISTURL%" PREFIXEDLABEL org.opensuse.reference="registry.opensuse.org/opensuse/distrobox-johanneskastl:%%PKG_VERSION%%.%RELEASE%"
Thanks in advance and have a nice day!
I guess you might missing the docker label helper service and the
replace-using-package-version service to substitute `%%PKG_VERSION%%`
and `%RELEASE%`.
Cheers,
Dan
--
Dan Čermák
Good morning Dan, long time no see... On 13.05.24 08:40 Dan Čermák wrote:
Johannes Kastl
writes:
Is there any documentation on how to use the BuildTags and the labels?
The only thing that I am aware of is this wiki page: https://en.opensuse.org/Building_derived_containers
Thanks!
And then there's my talk from the openSUSE Conference 2023: https://www.youtube.com/watch?v=d9LTLzoJzJE (slides are here: https://github.com/dcermak/building-containers-in-obs)
Yes, I remembered that one. Was hoping we had a written summary of the topic, but might as well rewatch it. It was fun.
I guess you might missing the docker label helper service and the replace-using-package-version service to substitute `%%PKG_VERSION%%` and `%RELEASE%`.
I found those bits and pieces in Richard's examples and have a working image. I also found out that I am not allowed to use tags like home/ojkastl_buildservice/... that match the final "path" in the registry. Rather than that I need to use opensuse (or bci or uyuni or ...), as other tags are not allowed. Same for the registry label. Kind Regards, Johannes
Hi Johannes,
Johannes Kastl
And then there's my talk from the openSUSE Conference 2023: https://www.youtube.com/watch?v=d9LTLzoJzJE (slides are here: https://github.com/dcermak/building-containers-in-obs)
Yes, I remembered that one. Was hoping we had a written summary of the topic, but might as well rewatch it. It was fun.
Thanks!
I guess you might missing the docker label helper service and the replace-using-package-version service to substitute `%%PKG_VERSION%%` and `%RELEASE%`.
I found those bits and pieces in Richard's examples and have a working image.
I also found out that I am not allowed to use tags like home/ojkastl_buildservice/... that match the final "path" in the registry. Rather than that I need to use opensuse (or bci or uyuni or ...), as other tags are not allowed.
Same for the registry label.
That looks like container-build-checks is failing your builds:
https://github.com/openSUSE/container-build-checks/
You should be able to override its configuration by providing your own
configuration file in a package that you preinstall. Or you can try to
Preinstall a different `container-build-checks-*` flavor[1].
Cheers,
Dan
Footnotes:
[1] currently there are container-build-checks-strict.noarch,
container-build-checks-vendor-SUSE.noarch and
container-build-checks-vendor-openSUSE.noarch
--
Dan Čermák
On 13.05.24 10:04 Dan Čermák wrote:
Johannes Kastl
writes: And then there's my talk from the openSUSE Conference 2023: https://www.youtube.com/watch?v=d9LTLzoJzJE (slides are here: https://github.com/dcermak/building-containers-in-obs)
Yes, I remembered that one. Was hoping we had a written summary of the topic, but might as well rewatch it. It was fun.
With the help of Dan's talk and slides I have successfully built two images in OBS. And I even got the second one building on top of the first. Apparently the long long registry URL that is shown for a container image on registry.opensuse.org is only useful for podman from the outside. Inside OBS, I could only reference an image in **the same project** by adding openSUSE:registry as a project in the containerfile build target:
<repository name="containerfile"> <path project="home:ojkastl_buildservice:containers:dumb-init" repository="15.6"/> <path project="home:ojkastl_buildservice:containers:helm-docs" repository="15.6"/> <path project="openSUSE:Registry" repository="standard"/> <path project="openSUSE:Containers:Leap:15.6" repository="containers"/> <arch>x86_64</arch> </repository>
The full path (used with podman) was not working. The path without the "registry.opensuse.org", i.e. "home/ojkastl_buildservice/containers/15.6/containerfile/ojkastl_buildservice/opensuse-leap-dumb-init" was not working. Using the tags from inside the image seems to work, but even then the images are sometimes blocked:
waiting for dod resources to appear: container:ojkastl_buildservice/opensuse-leap-dumb-init:15.5
https://build.opensuse.org/project/monitor/home:ojkastl_buildservice:contain...
Adding the registry project after openSUSE:Containers:Leap:15.6 lead to very funny errors with basic glibc dependencies missing for helm-docs. The documentation [here](https://opensource.suse.com/bci-docs/guides/building-on-top-of-bci/) states:
Skip this step if your image is in the same project and repository as the image that you are building.
Which obviously does not work, even if the prjconf and meta in the docus are similar to what I use. So, is there any documentation on this that I missed? Kind Regards, Johannes P.S. Have a lot of fun...
Answering myself... On 24.05.24 21:45 Johannes Kastl wrote:
Using the tags from inside the image seems to work, but even then the images are sometimes blocked:
waiting for dod resources to appear: container:ojkastl_buildservice/opensuse-leap-dumb-init:15.5
https://build.opensuse.org/project/monitor/home:ojkastl_buildservice:contain...
For some reason, adding the normal Leap 15.x repository as path started the builds. I am not sure I understand why, but it seems to work... Kind Regards, Johannes
On Sat, May 25, 2024 at 09:00:26AM +0200, Johannes Kastl wrote:
Answering myself...
On 24.05.24 21:45 Johannes Kastl wrote:
Using the tags from inside the image seems to work, but even then the images are sometimes blocked:
waiting for dod resources to appear: container:ojkastl_buildservice/opensuse-leap-dumb-init:15.5
https://build.opensuse.org/project/monitor/home:ojkastl_buildservice:contain...
For some reason, adding the normal Leap 15.x repository as path started the builds.
I am not sure I understand why, but it seems to work...
One of the issues usually is that only the last <path> entry is traversed recursively, so it might not find it if your last <path> did not have it in their path liist. Ciao, Marcus
Good morning Marcus, On 25.05.24 09:30 Marcus Meissner wrote:
One of the issues usually is that only the last <path> entry is traversed recursively, so it might not find it if your last <path> did not have it in their path liist.
But the image is from the same project. It should not need any project at all. At least, if images behave like packages in that regard, which the documentation hinted at... Kind Regards, Johannes
On Mai 25 2024, Johannes Kastl wrote:
Good morning Marcus,
On 25.05.24 09:30 Marcus Meissner wrote:
One of the issues usually is that only the last <path> entry is traversed recursively, so it might not find it if your last <path> did not have it in their path liist.
But the image is from the same project. It should not need any project at all. At least, if images behave like packages in that regard, which the documentation hinted at...
You can use osc buildinfo to find out exactly which repositories are being searched in which order. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Hi Andreas, On 25.05.24 11:59 Andreas Schwab wrote:
But the image is from the same project. It should not need any project at all. At least, if images behave like packages in that regard, which the documentation hinted at...
You can use osc buildinfo to find out exactly which repositories are being searched in which order.
But it should not have to search any other project. At least, if the reference in the FROM is correct. With packages it works, if "use for build" is enabled, which is normally the case... Kind Regards, Johannes
Hi Johannes,
Johannes Kastl
On 13.05.24 10:04 Dan Čermák wrote:
Johannes Kastl
writes: And then there's my talk from the openSUSE Conference 2023: https://www.youtube.com/watch?v=d9LTLzoJzJE (slides are here: https://github.com/dcermak/building-containers-in-obs)
Yes, I remembered that one. Was hoping we had a written summary of the topic, but might as well rewatch it. It was fun.
With the help of Dan's talk and slides I have successfully built two images in OBS. And I even got the second one building on top of the first.
Apparently the long long registry URL that is shown for a container image on registry.opensuse.org is only useful for podman from the outside.
Inside OBS, I could only reference an image in **the same project** by adding openSUSE:registry as a project in the containerfile build target:
<repository name="containerfile"> <path project="home:ojkastl_buildservice:containers:dumb-init" repository="15.6"/> <path project="home:ojkastl_buildservice:containers:helm-docs" repository="15.6"/> <path project="openSUSE:Registry" repository="standard"/> <path project="openSUSE:Containers:Leap:15.6" repository="containers"/> <arch>x86_64</arch> </repository>
The full path (used with podman) was not working. The path without the "registry.opensuse.org", i.e. "home/ojkastl_buildservice/containers/15.6/containerfile/ojkastl_buildservice/opensuse-leap-dumb-init" was not working. Using the tags from inside the image seems to work, but even then the images are sometimes blocked:
Generally, images are not referred to via the full path on the registry
(as that depends on the project name), but instead via the build tag
(the one that is added via the #!BuildTag magic comment).
In theory and if use_for_build is true, the built container should be
available in the buildroot and you can refer to it via:
```
FROM $BUILD_TAG_HERE
```
Cheers,
Dan
--
Dan Čermák
On 27.05.24 12:46 Dan Čermák wrote:
Generally, images are not referred to via the full path on the registry (as that depends on the project name), but instead via the build tag (the one that is added via the #!BuildTag magic comment).
In theory and if use_for_build is true, the built container should be available in the buildroot and you can refer to it via: ``` FROM $BUILD_TAG_HERE ```
Yes, that is what I figured out. It **should**... Kind Regards, Johannes
participants (4)
-
Andreas Schwab
-
Dan Čermák
-
Johannes Kastl
-
Marcus Meissner