The process of building docker images should be integrated into your CI pipeline.
The obvious approach
A standard solution is to setup an automated build between your image registry and your source control. The docker hub registry currently supports this with bitbucket and github.
A different approach
A basic solution is to run docker build with these considerations:
- Use the local git repo HEAD's SHA as a tag.
- Ensure the tag correctly represents the repository state, done by verifying nothing is in staging area or is untracked.
Combining the above into a shell script:
1 |
|
Now integrate this script with your local build tool. For example, in NodeJS package.json:
1 | { |
Why
This method is handy if either:
- You want to work locally.
- You're still figuring which image registry you want to work with.
- You just want to test out a project with basic continuous integration before advancing to a complete solution.