wharfie
Wharfie is a tool for building reproducable Docker images. Wharfie produces ready-to-run images by
injecting a user source into a docker image and /preparing/ a new Docker image which incorporates
the base image and built source, and is ready to use with docker run. Wharfie supports
incremental builds which re-use previously downloaded dependencies, previously built artifacts, etc.
Interested in learning more? Read on!
Basic wharfie builds
Wharfie accepts the following inputs to do a build:
- Application source: this can be source code, zipped source, a binary, etc.
- Wharfie source image: the basis for the new image to build
- Prior build image: optional, a previously built wharfie output image to pull build artifacts from
The build process is as follows:
- Wharfie pulls the source image if it is not already present on the system
- Wharfie generates a
Dockerfileto describe the output image:- Based on the wharfie source image
- Adds the application source at
/usr/sourcein the container - Calls
/usr/bin/preparein the container - Sets the image's default command to
/usr/bin/run
- Wharfie builds the new image from the
Dockerfileusingdocker build
Anatomy of a wharfie source image
Building wharfie source images is as easy as implementing two scripts. Wharfie expects the
following scripts in /usr/bin:
prepare: This script is responsible for building and/or deploying the sourcerun: This script is responsible for running the deployed source
Incremental wharfie builds
When you call wharfie build with the --incremental flag, the build process is as follows:
- Wharfie pulls the source image if it is not already present on the system
- Wharfie pulls the incremental build image if it is not already present on the system
- Wharfie creates a new docker container from the prior image, with a volume in
/usr/artifacts - Wharfie runs
/usr/bin/save-artifactin this container - Wharfie creates a new docker container from the source image, mounting the volumes from the incremental build container
- Wharfie bind-mounts the application source into
/usr/sourcein the container - Wharfie runs
/usr/bin/restore-artifactto restore the build context from the prior image - Wharfie calls
/usr/bin/preparein the container - Wharfie commits the container as a new image, setting the new image's command to
/usr/bin/run
There are two more scripts to implement to support incremental builds:
save-artifact: This script is responsible for moving build dependencies to/usr/artifactsrestore-artifact: This script is responsible for restoring a build environment from/usr/artifacts