-
Notifications
You must be signed in to change notification settings - Fork 66
Scenario build new releases
Version: G3v2
Updated: 2022-11-04
This is a local stage scenario using the second version (G3v2) of the building pipeline.
It's assumed that you have already prepared the local stage as it is described on the page Local building example.
Our goal is to build a new release of an existing image.
This scenario could be performed after the scenario Check if image refresh is needed, but it depends on it only in some cases.
Typically it is necessary to execute the hook script pre_build
first only in the following cases:
-
If you first want to check, if the image needs to be refreshed.
-
If you want, that the new image has the current
version-sticker
label value. -
If you want to execute the complete building pipeline.
Let's build a new release of the image with Firefox. It would be the image accetto/ubuntu-vnc-xfce-g3-firefox.
However, on our current local stage the image will be named accetto/devops-headless-ubuntu-g3:latest-firefox
.
Why this name? It is explained on the page Check if image refresh is needed.
They are actually only two simple scenarios in this case, because building images using this building pipeline is really easy.
Remark: Actually we can build images really simply by using the provided utility script ci-builder.sh
(check the page Local building example for more information). However, we want to illustrate some concepts here.
In this case we are interested only in quick building of a new image locally.
We do not care about the value of the version-sticker
label. We are also not interested in the publishing the image or its README file to the Docker Hub.
Building the image in this case is really simple. We don't need to do any additional configuration and we also don't need to execute the pre_build
hook script first.
We can execute the hook script build
straight away. We will assume that the builder's cache has already been refreshed, so we will not use the additional argument --no-cache
:
### PWD = project's root directory
./docker/hooks/pre_build dev latest-firefox
### or also
./builder.sh latest-firefox pre_build
That's all. We've got our new image accetto/devops-headless-ubuntu-g3:latest-firefox
.
Why this name? It is explained on the page Check if image refresh is needed.
The building itself should be really quick and its console output is not so interesting. Maybe only the lines that show that the current g3-cache
content has been used and nothing needed to be downloaded:
==> G3-CACHE hit file 'tigervnc-1.12.0.x86_64.tar.gz' in section 'tigervnc'
==> G3-CACHE hit file 'v1.3.0.tar.gz' in section 'novnc'
==> G3-CACHE hit file 'v0.10.0.tar.gz' in section 'websockify'
Or the line, which shows the actual building time:
Current timestamp: 2022-11-04T17:20:44Z
Let's check, if this value is indeed stored in the label created
of the new image:
docker inspect accetto/devops-headless-ubuntu-g3:latest-firefox
Scroll down to the Labels
part of the output:
"Labels": {
"any.accetto.version-sticker": "null",
"org.label-schema.vcs-ref": "a8b088d",
"org.label-schema.vcs-url": "https://github.com/accetto/ubuntu-vnc-xfce-g3",
"org.opencontainers.image.authors": "accetto",
"org.opencontainers.image.created": "2022-11-04T17:20:44Z",
"org.opencontainers.image.description": "Headless Ubuntu/Xfce/VNC/noVNC containers with Internet browsers",
"org.opencontainers.image.documentation": "https://github.com/accetto/ubuntu-vnc-xfce-g3",
"org.opencontainers.image.source": "https://github.com/accetto/ubuntu-vnc-xfce-g3",
"org.opencontainers.image.title": "accetto/ubuntu-vnc-xfce-g3",
"org.opencontainers.image.url": "https://github.com/accetto/ubuntu-vnc-xfce-g3",
"org.opencontainers.image.vendor": "https://github.com/accetto",
"org.opencontainers.image.version": "latest-firefox"
}
You can see, that the correct building time is stored in the image metadata even by the straight-away building.
On the other hand, the value of the version-sticker
label is currently null
. Let's fix it in the next scenario.
This scenario is almost identical to the previous one, with the difference that we want to persist the correct current version-sticker
label value.
We can get it by executing the hoot script pre_build
first. It will generate the necessary helper files as it is described on the page Check if image refresh is needed.
Next we will execute the hook script build
exactly as described above.
Let's skip the repetition and inspect the Labels
of the new image:
"Labels": {
"any.accetto.version-sticker": "ubuntu20.04.5-firefox106.0.2",
"org.label-schema.vcs-ref": "a8b088d",
"org.label-schema.vcs-url": "https://github.com/accetto/ubuntu-vnc-xfce-g3",
"org.opencontainers.image.authors": "accetto",
"org.opencontainers.image.created": "2022-11-04T17:32:43Z",
"org.opencontainers.image.description": "Headless Ubuntu/Xfce/VNC/noVNC containers with Internet browsers",
"org.opencontainers.image.documentation": "https://github.com/accetto/ubuntu-vnc-xfce-g3",
"org.opencontainers.image.source": "https://github.com/accetto/ubuntu-vnc-xfce-g3",
"org.opencontainers.image.title": "accetto/ubuntu-vnc-xfce-g3",
"org.opencontainers.image.url": "https://github.com/accetto/ubuntu-vnc-xfce-g3",
"org.opencontainers.image.vendor": "https://github.com/accetto",
"org.opencontainers.image.version": "latest-firefox"
}
We can see, that the version-sticker
label really contains the value ubuntu20.04.5-firefox106.0.2
, which is the correct current value at the time of writing this text.