MyNixOS website logo
Description

Assembles many Dockerfiles in one.

Buffet 🍜

Build Package

Assemble many Dockerfiles in a single Dockerfile. This gives you the convenience of one Docker image with your favorite tools while keeping a separate Dockerfile per tool.

Demo example

A Dockerfile for Prettier

FROM alpine:3.12.0
RUN apk add --no-cache yarn~=1.22 \
 && yarn global add [email protected]
WORKDIR /workdir

plus a Dockerfile for HTML Tidy

FROM alpine:3.12.0
RUN apk add --no-cache tidyhtml~=5.6
WORKDIR /workdir

are automatically assembled in a single Dockerfile

FROM alpine:3.12.0
RUN apk add --no-cache yarn~=1.22 \
 && yarn global add [email protected] \
 && apk add --no-cache tidyhtml~=5.6
WORKDIR /workdir

You can try this yourself by running

buffet assemble examples/minimal_demonstration

See Code Cleaner Buffet for an application of this.

Installation

For a quick start, use the Docker image evolutics/buffet. I recommend a Bash alias like

alias buffet='docker run --rm --volume "$(pwd)":/workdir evolutics/buffet'

You are ready when

buffet --help

works.

Alternatively, you can do a native installation with stack install buffet or cabal install buffet.

Usage example

Say we work on a simple website with HTML code that we would like to format, clean up, and validate. For this purpose, we choose the tools Prettier and HTML Tidy, which we plan use in continuous integration via a Docker image.

For the following, we assume you first run

git clone https://github.com/evolutics/buffet.git
cd buffet

The source code for this and other examples is in the examples folder.

Assembling

In the subfolders of examples/quick_start, you see a Dockerfile for Prettier and another Dockerfile for HTML Tidy. These Dockerfiles (called "dishes") are the modular toy blocks, which we now automatically combine to one Dockerfile (called "buffet") by running

buffet assemble examples/quick_start

This prints a Dockerfile based on the subfolders of examples/quick_start to stdout. From this, we can then build a Docker image mona_linta with

buffet assemble examples/quick_start | docker build --tag mona_linta -

Note the hyphen - at the end that makes Docker read the Dockerfile from stdin.

Testing

As a demo that our Docker image works as expected, run

docker run -it --rm mona_linta
prettier --version
tidy --version

To integrate a check like prettier --version as a test of the tool installation, add a HEALTHCHECK instruction as you see in the Dockerfile for Prettier. The exit status of such a command is then reported when you run our example test suite with

buffet test --arguments examples/quick_start/test_arguments.yaml \
  examples/quick_start

This builds a Docker image to then run the tests. Only the dishes referred in the file test_arguments.yaml are tested.

Note: As buffet test … executes Docker commands, a native installation is required here.

If you like, try adding a test for HTML Tidy.

Documenting

You can generate documentation with

buffet document --template examples/quick_start/document_template.md.mustache \
  examples/quick_start

This renders the template document_template.md.mustache. To print the raw template context, omit this option as in

buffet document examples/quick_start

Among others, data from LABEL instructions is integrated in the template context.

API usage

You may like to programmatically process the parsed source Dockerfiles. To print an intermediate representation in JSON, run

buffet parse examples/quick_start

Terminology

  • Buffet: A Dockerfile automatically assembled based on many dishes.
  • Dish: A Dockerfile, usually providing a specific command-line tool.
  • Menu: Configuration with a list of dishes to be assembled in a buffet.
Metadata

Version

1.0.1

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows