You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org
Blubber
Blubber is a highly opinionated abstraction for container build configurations and a command-line compiler which currently supports outputting multi-stage Dockerfiles. It aims to provide a handful of declarative constructs that accomplish build configuration in a more secure and determinate way than running ad-hoc commands.
Installation
Requirements
Blubber requires
- Go 1.7+ (for the context package and vendored dependencies)
- git
- docker 17.06+ (for multistage build support)
$ export GOPATH="$HOME/go"
$ go get phabricator.wikimedia.org/source/blubber
This will install blubber to ~/go/bin/blubber
Use
Blubber takes opinionated input files in yaml
format and outputs a variant of a Dockerfile
s that should be safe to run for their intended purpose. The number of potential variants in a Blubber config are not limited. Variants can inherit instructions, packages, and runtime environments from one another using the includes
directive.
Below is an example blubber.yaml
for Mathoid
base: docker-registry.wikimedia.org/nodejs-slim
apt: { packages: [librsvg2-2] }
runs:
in: /srv/service
as: runuser
uid: 666
gid: 666
environment: { APP_BASE_PATH: /srv/service }
variants:
build:
base: docker-registry.wikimedia.org/nodejs-devel
apt: { packages: [librsvg2-dev, git, pkg-config, build-essential] }
node: { dependencies: true }
runs: { environment: { LINK: g++ } }
development:
includes: [build]
entrypoint: [node, server.js]
test:
includes: [build]
entrypoint: [npm, test]
prep:
includes: [build]
node: { env: production }
production:
copies: prep
node: { env: production }
entrypoint: [node, server.js]
Example usage
In order to output a Dockerfile
, Blubber needs a configuration file and a variant that you want to output. The available variants in the file above are build
, development
, test
, prep
, and production
. To run current tests in a test build using blubber pass the test variant to Docker
to build and run. For example in the Mathoid repository, the Blubber configuration file lives under the path dist/pipeline/blubber.yaml
:
$ cd ~/src/mathoid
$ blubber dist/pipeline/blubber.yaml test | docker build -t mathoid-test-$(date --iso) -f - .
$ docker run --rm -it mathoid-test-$(date --iso)
...
$ docker rmi mathoid-test-$(date --iso)