Since c5720564 (Force version to be regenerated on each compile,
2021-06-01) `autogen/version.c` must be generated during the build
process, but the build instructions in the `Dockerfile` have not been
updated accordingly. Since then two commits [1] on separate branches
updated `Dockerfile` to deal with the missing file, and now
`autogen/version.c` is generated twice during a containerized build.
Remove all redundant commands from `Dockerfile`'s `CMD` instruction to
generate `autogen/version.c` and its subdirectory only once.
[1] 8e9745a6 (Add version.c generation to dockerbuild and actions,
2021-11-02)
7f013d6d (Fixed dockerbuild.sh, now run as user (instead
of root) and fixed the autogeneration of version.c,
2021-09-16)
The `Dockerfile` uses separate `RUN` instructions for each `apt-get`
command. Docker's documentation considers this as an anti-pattern,
because it can lead to caching issues [1].
Follow Docker's advice, and combine all `apt-get` invocations into a
single `RUN` instruction with an &&-chaned list of commands. This
makes it rather hard to tell which command produces which output, so
insert a `set -x` at the beginning of the command chain to generate a
trace of the executed commands.
[1] Each `RUN` instruction, including subsequent `RUN apt-get update`
and `RUN apt-get install` instructions create separate layers that
are stored in the Docker cache. If someone were to modify the
list of list of packages to install, then Docker would re-use the
layer created by the prior `RUN apt-get update` instruction,
meaning that `apt-get install` would use an outdate package list.
This can lead to outdated packages to be installed, or a failure
if the outdated version is not present anymore in the package
repository.
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
Added command to makefile to generate enums.h for Arduino use. Did the same for the dockerfile. Added note on developer-guide markdown file to also update enums.h along with enums.py.
- Docker image now only contain the build environment, not the code.
This save development time by not rebuilding docker image everytime
source code change.
- Build by mounting repo's directory into container, build output and
intermediate artifacts is available for inspecting if build fail
midway.