« 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:

invoke.yaml
matrix:
  dist:
    ubuntu:
    - trusty
    - xenial
    - bionic
    debian:
    - stretch
    centos:
    - 7
  salt:
    - stable
    - stable 2016.3
    - stable 2017.7
    - develop
  salt-formulas:
    - 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.

DockerMake.yaml
    [first_image_name]:
      FROM: [named_base_image]
      build: |
        RUN [something]
        ADD [something else]
        [Dockerfile commands go here]
    [another_image_name]:
     requires:
       - [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:

usage.sh
    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 \
      --push

Good enough?

Comments

comments powered by Disqus