« Back to home

Image builds with DockerMake

Dockerfile is nice, but it’s a puppet toy when it comes to scale. I am looking for a solution to consistently build many docker images with shared layers and consistent and predictable build workflow.

TL;DR πŸ”—︎

My use-case is simple. I want to build matrix of docker images for kitchen-salt CI, containerized Salt-Master and bare-bone OS boilerplates. With Salt, salt formulas installed or without it at all. That makes more than 60 image versions.

My matrix looks like:

    - trusty
    - xenial
    - bionic
    - stretch
    - 7
    - stable
    - stable 2016.3
    - stable 2017.7
    - develop
    - stable
    - nightly

DockerMake πŸ”—︎

I choosed DockerMake as it is:

  • lite

  • flexible enough

  • logic/isolated/layers

  • active in development

How it works you may find out from the following snippet.

      FROM: [named_base_image]
      build: |
        RUN [something]
        ADD [something else]
        [Dockerfile commands go here]
       - [first_image_name]
     build: |
       [additional Dockerfile instructions]

For all features check avirshup repo or my final implementation for docker-salt-formulas.

Extend with "makefile" with PyInvoke πŸ”—︎

DockerMake is worth to indepotently declare individual layers. However if used standalone bit fails to use key/args in layer, image, variable names.

To solve the issue I wrote simple "makefile" specification with PyInvoke.

    tasks.py     # Script to write tasks for pyinvoke
    invoke.yaml  # Configuration file (optional)

Finally to build images or list individual targets I run these options:

    inv --list
    inv all --dry
    inv all --dry-targets

    # build whole matrix
    inv all --push
    inv all --push -w    # warnings only: to survive on errors

    # individual targets
    # invoke [target] [--[args][=value]] [--push]
    invoke all --dry-targets --filter "{'target':'saltstack', 'salt': 'stable'}"
    invoke build wheelhouse --require "salt salt-formulas wheel" \
      --dist=debian --dist-rel=stretch \
      --salt=develop --formula-rev=nightly \

Good enough?


comments powered by Disqus