Due to build time restrictions on Docker Hub, I decided to split the Dockerfile
of a time-consuming automated build into three files.
Each one of those "sub-builds" finishes within Docker Hub's time limits.
I have now the following setup within the same repository:
| branch | dockerfile | tag |
| ------ | ------------------ | ------ |
| master | /step-1.Dockerfile | step-1 |
| master | /step-2.Dockerfile | step-2 |
| master | /step-3.Dockerfile | step-3 |
The images build on each other in the following order:
step-1.Dockerfile
:FROM ubuntu
step-2.Dockerfile
:FROM me/complex-image:step-1
step-3.Dockerfile
:FROM me/complex-image:step-2
A separate web application triggers the building of step-1
using the "build trigger" URL provided by Docker Hub (to which the {"docker_tag": "step-1"}'
payload is added). However, Docker Hub doesn't provide a way to automatically trigger step-2
and then step-3
afterwards.
How can I automatically trigger the following build steps in their respective order?** (i.e., trigger step-2
after step-1
finishes. Then, trigger step-3
after step-2
finishes).
NB: I don't want to set up separate repositories for each of step-i
then link them using Docker Hub's "Repository Links." I just want to link tags in the same repository.
Note: Until now, my solution is to attach a Docker Hub Webhook to a web application that I've made. When step-n
finishes, (i.e., calls my web application's URL with a JSON file containing the tag name of step-n
) the web application uses the "build trigger" to trigger step-n+1
. It works as expected, however, I'm wondering whether there's a "better" way of doing things.
As requested by Ken Cochrane, here are the initial Dockerfile
as well as the "build script" that it uses. I was just trying to dockerize Cling (a C++ interpreter). It needs to compile LLVM, Clang and Cling. As you might expect, depending on the machine, it needs a few hours to do so, and Docker Hub allows "only" 2-hour builds at most :) The "sub build" images that I added later (still in the develop
branch) build a part of the whole thing each. I'm not sure that there is any further optimization to be made here.
Also, in order to test various ideas (and avoid waiting h-hours for the result) I have setup another repository with a similar structure (the only difference is that its Dockerfile
s don't do as much work).
UPDATE 1: On Option 5: as expected, the curl
from step-1.Dockerfile
has been ignored:
Settings → Build Triggers → Last 10 Trigger Logs
| Date/Time | IP Address | Status | Status Description | Request Body | Build Request |
| ------------------------- | --------------- | ------- | ------------------------ | -------------------------- | ------------- |
| April 30th, 2016, 1:18 am | <my.ip.v4.addr> | ignored | Ignored, build throttle. | {u'docker_tag': u'step-2'} | null |
Another problem with this approach is that it requires me to put the build trigger's (secret) token in the Dockerfile
for everyone to see :) (hopefully, Docker Hub has an option to invalidate it and regenerate another one)
UPDATE 2: Here is my current attempt: It is basically a Heroku-hosted application that has an APScheduler periodic "trigger" that starts the initial build step, and a Flask webhook handler that "propagates" the build (i.e., it has the ordered list of build tags. Each time it is called by the webhook, it triggers the next build step).