I've thrown a lot of commits and time every few weeks at this, so now that I've figured it out, I'll give you an idea of what I needed to do to make it work in a micro-post.
Step 1: You need a custom build step, to do this, you need to create a file
hooks/build in your repo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
There's a list of examples in this repo - though the build
one is too simple for our needs here. If you need something that's not there, then remove the comment marker before
printenv to the script to see
what env vars are available
(here's an example build).
Step 2: Edit your
Dockerfile to take the additional arguments
1 2 3 4 5 6 7 8 9 10 11 12
Err, that should be everything. I mean, I did call it a micro-post. Trying to implement this has broken the Peril runner a bunch of times on staging, so I'm mainly just helping out other docker newbies.
Some links that helped me get there:
- Add git commit hash to ENV
- Feature request: Build args on docker hub
- Inject Git source commit metadata into the image
- Configure automated builds from GitHub
Remember folks, Ash says you should write as you learn, so write up those small wins.