Build and publish containers with OBS¶
Why use the Open Build Service?
- it will host the latest successful build
- it automatically rebuilds containers if included packages or dependencies get updates
General prerequisites:
- get an account on the openSUSE Build Service
- install the command-line interface for OBS:
osc
Browser web interface¶
Direct link to video, in case it does not show up below
Command-line interface¶
1. Create new project¶
1.1. Meta configuration¶
Run
and add a containers
repository for your new project:
<project name="home:eroca:test">
<title/>
<description/>
<person userid="eroca" role="bugowner"/>
<person userid="eroca" role="maintainer"/>
<repository name="containers">
<path project="openSUSE:Containers:Tumbleweed" repository="containers"/>
<arch>x86_64</arch>
</repository>
</project>
This way you have created a new project and configured a repository.
1.2. Project configuration¶
Run
and add the following configuration:
After this step you have enabled container builds in the repository.
2. Create new package¶
2.1. Checkout project¶
2.2. Create new package¶
3. Add Dockerfile¶
Open your favorite editor, use the following as template:
#!BuildTag: hello
FROM opensuse/tumbleweed
# add repositories as needed
# RUN zypper addrepo https://download.opensuse.org/repositories/home:eroca:test/openSUSE_Tumbleweed/ "home:eroca:test"
# RUN zypper modifyrepo -p 97 "home:eroca:test"
# RUN zypper --gpg-auto-import-keys refresh
# install packages
RUN zypper --non-interactive install hello
CMD hello
then run:
Noticed the #!BuildTag
line at the beginning? That's specific to OBS; it's your container name.
4. Build locally¶
Building locally lets you fix any errors before commiting, which also saves server resources.
You can of course just use docker or podman for that as well.
5. Commit changes¶
Commiting changes triggers building and publishing on the server.
Check results, will take a few minutes to finish:
> osc results --watch
containers x86_64 building
containers x86_64 finished*
containers x86_64 succeeded*
^C