-
Notifications
You must be signed in to change notification settings - Fork 45
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
riotdocker-base: Split out build logic #225
base: master
Are you sure you want to change the base?
Conversation
riotdocker-base/build.sh
Outdated
NORMAL="\e[0m" | ||
|
||
step() { | ||
export COUNTER_SUBSTEP=0 |
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 don't think export is needed.
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'm a bit conflicted about duplicating Docker functionality, but understand that there are two reasons to go this path:
-
It reduces the number of layers in the image.
There is the "squash" image option, which would have the same effect, but is documented to be "experimental".
We currently go out of our way to make the many images not much worse than a single one by cleaning up right after each step (if we did apt-get clean in a separate run command, the temporary files would linger). Embracing --squash would be an alternative here that'd solve the readability issues (the
&&
chain would be replaced by individual RUN commands).Is there a concrete case where
--squash
would not suffice, or is it really "that experimental"? -
This makes the setup easy to port over to non-Docker situations, but rummaging around in
/root
is probably unacceptable in all but container images. Is there a concrete scenario in which this would be used?
(I trust you have good answers to both parts; I'm generally OK with going this path, but I'd like to have these deliberations documented before hitting the button).
apt-get -y --no-install-recommends install git | ||
|
||
substep "Installing Python" | ||
apt-get -y --no-install-recommends install \ |
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.
Doing multiple apt-get install in separate steps incurs some run-time cost from hooks being run after each apt-get.
But fine with me -- it's little time spent in CI, and much better readability gained.
The bind-mounting them instead into e.g.
This doesn't work with the CI we use (at least yet). But I need the layers to be reduced to a sane number now. Honestly, I still fail to understand why there is not dedicated command to generate a layer at sensible points in time, but rather force users to do |
I was mentioning Do you have a pointer to the setups you'll use Is the general roadmap behind this PR that once riotdocker-base is done, other images would follow? One more minor suggestion (sic): If the step/substep functions detect that their terminal is GitHub, they could emit |
My roadmap would be to first convert all docker containers to only add one layer on top of what they are based on. Afterwards, the toolchain installation stuff could be added to RIOT-OS/RIOT, so that Ubuntu users could just run that to install the toolchains. Once that is in place, the So basically, |
riotdocker-base/build.sh
Outdated
} | ||
|
||
endstep() { | ||
if [ -n "${GITHUB_RUN_ID}" ]; then |
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.
This apparently doesn't work. It actually is reassuring that environment variables do not leak into the container; but now I have no idea how to emit the ::group::
... ::endgroup::
only when run in Github.
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.
Yeah, if only they did the regular thing, advertised that they are their own TERM, or just packed these in vendor specific OSC codes.
Might be that the Docker environment would need to pass on the variable – but unless you particularly feel like it, let's not spend more time on this.
Ah, so while this particular build would not be run (neither setup_git nor /data/riotbuild makes sense outside), later parts would be shaped to be suitable for running on Ubuntu. I'd still recommend against doing that unchecked (maybe inside a checkinstall), but that will be a matter of preferences then. All fine with me, please squash / finalize. (Not pressing ACK here yet because unlike in RIOT there are no checks against accidental merges in the presence of fixups, AFAICT). |
51867f4
to
706e704
Compare
This splits out all the build logic into the bash script build.sh. This has two advantages: - Only a single layer is added for this Dockerfile - This reduces overhead, especially with the VFS storage driver - Still takes full advantage of de-duplication of the layers concept: No image is based on intermediate steps anyway - Improves maintainability - Strict split of meta data (--> Dockerfile) and build commands (--> build.sh) - No need for long `cmd_a && cmd_b && cmd_c && cmd_d` stuff anymore
706e704
to
ce7dd92
Compare
The output of https://github.com/RIOT-OS/riotdocker/actions/runs/4240464444/jobs/7369508764 shows that Since this apparently doesn't work, I just reverted to using human readable step indication. |
IMO this is now ready |
This splits out all the build logic into the bash script build.sh. This has two advantages:
cmd_a && cmd_b && cmd_c && cmd_d
stuff anymore