Bug #5017
ttcn3-*-test/Dockerfile: Does not invalidate cache on changes of deps/Makefile
100%
Description
The typical docker files for packaging one of our test suites looks like this:
ARG USER FROM $USER/debian-stretch-titan RUN git clone git://git.osmocom.org/osmo-ttcn3-hacks.git RUN cd osmo-ttcn3-hacks && \ git checkout -f -B master origin/master && \ make deps ARG OSMO_TTCN3_BRANCH="master" ADD http://git.osmocom.org/osmo-ttcn3-hacks/patch?h=$OSMO_TTCN3_BRANCH /tmp/commit RUN cd osmo-ttcn3-hacks && \ git fetch && \ git checkout $OSMO_TTCN3_BRANCH && \ (git symbolic-ref -q HEAD && git reset --hard origin/$OSMO_TTCN3_BRANCH || exit 1); \ git rev-parse --abbrev-ref HEAD && git rev-parse HEAD && \ make ggsn_tests
We just ran into massive build failures, as an update to Makefile/deps does not trigger re-build of the Docker images. The "ADD" of the http;//git.osmocom.org URL is done only after the "build dependencies step. So no matter what one commits to deps/Makefile, the container will always start at that "ADD", keeping the old dependencies without any way to force a related rebuild other than manually logging into all build slaves and deleting the respective images (basically all of them).
Now we could simply move that ADD line up in all dockerfiles, but I think the solution is actually rather to include the 'deps' in the debian-stretch-titan image altogether. We could then (hopefully)- use jenkins to trigger a build of that image whenever there's a change in the deps/ subdirectory of osmo-ttcn3-hacks.git only
- push that image to registry.osmocom.org
- make all other build jobs use that image from the registry, rather than rebuilding from scratch
This approach has the added benefit of reducing build times (cloning dozens of 'deps' git repositories on each build of each slave) and of course reduce traffic and unneccessary load on the git servers.
Checklist
- clone osmo-ttcn3-hacks and deps in debian-stretch-titan instead of ttcn3-*/Dockerfile
- make sure 'make deps' runs if OSMO_TTCN3_BRANCH change results in different deps
- set it up to push debian-stretch-titan to registry.osmocom.org
- make all other build jobs use that image from the registry, rather than rebuilding from scratch
- trigger rebuilds of debian-stretch-titan for registry.osmocom.org, if deps change
Associated revisions
ttcn3: move initial clone to debian-stretch-titan
Clone the osmo-ttcn3-hacks and all dependency repositories less often by
moving related commands to the shared debian-stretch-titan image.
Remove the 'git checkout -f -B master origin/master' line, because the
master branch is checked out by default.
While at it, move the shared "git config" commands too, and move them
before cloning the repositories, so they don't run again whenever the
deps change (logic to invalidate the cache if deps change will be added
in the next patch).
Related: OS#5017
Change-Id: I2bb142dce061eba4b6a828c4e435510e309989fd
debian-stretch-titan: update deps on change
After the initial clone of osmo-ttcn3-hacks and deps, let docker
download deps/Makefile to invalidate the cache if the file changed.
Run "git pull" and "make deps" afterwards, but only if the Makefile is
different. The "if" saves time in the initial build of the image, it
avoids the "git fetch" on every dependency repository during "make deps".
Related: OS#5017
Change-Id: I56673312cfb23375d67900016aaac1931f677275
ttcn3: move prepare code to shared script
Move the git fetch/checkout code and make call to build the testsuite,
to debian-stretch-titan/ttcn3-docker-prepare.sh. In the next patch, I
will extend the script to update deps right before building too (e.g.
because OSMO_TTCN3_BRANCH changed).
Related: OS#5017
Change-Id: I4b5bedf058dc527e821f9b7204c632820e671af9
debian-stretch-titan: prepare: run 'make deps'
Run 'make deps' in ttcn3-docker-prepare.sh, if needed.
Related: OS#5017
Change-Id: I9085203b27d310b63a035fd71f7c2a78d02710d4
debian-stretch-titan: prepare: start/stop links
Create symlinks to ttcn3-*-start.sh and ttcn3-*-stop.sh in the
prepare.sh script instead of in each of the ttcn3 Dockerfiles.
Related: OS#5017
Change-Id: I634cf71cff7936efe6e0461d21dc1119de922ada
ttcn3: move shared run code to script
While I'm at it with tidying up the Dockerfiles, create a
ttcn3-docker-run.sh with shared run code.
Related: OS#5017
Change-Id: Id90769707158f0488eca2313c57b99ea7a4a27c8
ttcn3-{fr,gbproxy}-test: use ttcn3-docker-run too
Move the shared pipework script to the base image, and call it in
ttcn3-docker-run.sh if WAIT_FOR_NETDEV is set. Use ttcn3-docker-run.sh
as entrypoint in both Dockerfiles and remove the custom entrypoint
scripts (which are the same as ttcn3-docker-run.sh now).
Related: OS#5017
Change-Id: I2889abe94ed522a205890e5cb39e09cbebfbd820
ttcn3: use REGISTRY arg with debian-stretch-titan
Allow jenkins to fetch the image from our private docker registry.
Outside of jenkins, the image is built locally just like before.
Related: OS#5017
Change-Id: I46cc176ea09d8badc359b627d7ce2f459211258c
History
#2 Updated by osmith 24 days ago
- Checklist item clone osmo-ttcn3-hacks and deps in debian-stretch-titan instead of ttcn3-*/Dockerfile added
- Checklist item make sure 'make deps' runs if OSMO_TTCN3_BRANCH change results in different deps added
- Checklist item set it up to push debian-stretch-titan to registry.osmocom.org added
- Checklist item make all other build jobs use that image from the registry, rather than rebuilding from scratch added
- Checklist item trigger rebuilds of debian-stretch-titan for registry.osmocom.org, if deps change added
- % Done changed from 0 to 60
[...] the solution is actually rather to include the 'deps' in the debian-stretch-titan image altogether
Done (and while at it, some related redundancy moved from ttcn3-*/Dockerfile to debian-stretch-titan):
#3 Updated by osmith 23 days ago
- Checklist item set it up to push debian-stretch-titan to registry.osmocom.org set to Done
- Checklist item make all other build jobs use that image from the registry, rather than rebuilding from scratch set to Done
- Checklist item trigger rebuilds of debian-stretch-titan for registry.osmocom.org, if deps change set to Done
- % Done changed from 60 to 90
docker-playground patches rolled out, and new registry related patches submitted (under same topic, see link above).
ttcn3: remove /root/projects/git symlink
Remove leftover from old TTCN-3 build scripts, before refactoring ttcn3
Dockerfiles. This line has already been removed in 357ec806 from 2017 for
ggsn-test.
In osmo-ttcn3-hacks.git, this is only referenced in the obsolete
bin/install.script (looks like we could remove that, together with the
rest of the bin dir?).
Related: OS#5017
Change-Id: Id23e7fae58ba246916a38aa0a10035d4f67f7588