You are browsing a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org

Blubber: Difference between revisions

From Wikitech-static
Jump to navigation Jump to search
imported>Thcipriani
(make example section)
 
imported>Thcipriani
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[File:Blubber Logo.png|thumb]]
[[Image:Blubber logo.svg|300px|frameless|center|middle]]


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.
<templatestyles src="Template:FancyDoc/style.css" />
<div class="fancydoc-header fancydoc--green-border">
Blubber creates Dockerfiles from a higher level description expressed as YAML. Blubber is a highly opinionated abstraction for container build configurations and a command-line compiler which currently supports outputting [https://docs.docker.com/develop/develop-images/multistage-build/ multi-stage] Dockerfiles.


== Installation ==
It aims to provide a handful of declarative constructs that accomplish build configuration in a more secure and deterministic way than running ad-hoc commands.


=== Requirements ===
Blubber is used by Wikimedia CI to test code and publish production-ready Docker images.
Blubber requires
</div>


* Go 1.7+ (for the context package and vendored dependencies)
<templatestyles src="Template:Portal_list_item/styles.css" />
* git
<div class="mw-tpl-portal-list"><div class="mw-tpl-portal-list-caption">Documentation</div>
* docker 17.06+ (for multistage build support)
{{Portal list item noimage
|name=Getting Blubber
|link=Blubber/Download
|description=Download the Blubber command line application
}}
{{Portal list item noimage
|name=Getting started
|link=Blubber/Tutorial
|description=Try a walkthrough that helps you create your first <code>Blubberfile</code>, create your first Docker images, and start using Blubber for your project
}}
{{Portal list item noimage
|name=Use in the Wikimedia Pipeline
|link=Blubber/Pipeline
|description=Wikimedia's [[Deployment pipeline]] pipeline project makes use of Blubber to run tests and publish images.
}}
{{Portal list item noimage
|name=Concepts
|link=Blubber/Idea
|description=Blubber's background, philosophy, and implementation
}}
{{Portal list item noimage
|name=User Guide
|link=Blubber/User Guide
|description=Detailed Blubber User Guide
}}
</div>


<syntaxhighlight lang=sh>
== Developers ==
$ export GOPATH="$HOME/go"
$ go get phabricator.wikimedia.org/source/blubber
</syntaxhighlight>


This will install blubber to <code>~/go/bin/blubber</code>
There is a short guide to [https://gitlab.wikimedia.org/repos/releng/blubber/-/blob/main/CONTRIBUTING.md#contributing-to-blubber contributing to Blubber] for developers in the [https://gitlab.wikimedia.org/repos/releng/blubber Blubber repository] on Gerrit.
 
== Use ==
 
Blubber takes opinionated input files in <code>yaml</code> format and outputs a variant of a <code>Dockerfile</code>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 <code>includes</code> directive.
 
Below is an example <code>blubber.yaml</code> for [[Mathoid]]
 
<syntaxhighlight lang=yaml>
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]
</syntaxhighlight>
 
== Example usage ==
 
In order to output a <code>Dockerfile</code>, Blubber needs a configuration file and a variant that you want to output. The available variants in the file above are <code>build</code>, <code>development</code>, <code>test</code>, <code>prep</code>, and <code>production</code>. To run current tests in a test build using blubber pass the test variant to <code>Docker</code> to build and run. For example in the Mathoid repository, the Blubber configuration file lives under the path <code>dist/pipeline/blubber.yaml</code>:
 
<syntaxhighlight lang=sh>
$ 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)
</syntaxhighlight>

Latest revision as of 22:00, 10 November 2022

Blubber logo.svg

Blubber creates Dockerfiles from a higher level description expressed as YAML. 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 deterministic way than running ad-hoc commands.

Blubber is used by Wikimedia CI to test code and publish production-ready Docker images.

Documentation
Download the Blubber command line application
Try a walkthrough that helps you create your first Blubberfile, create your first Docker images, and start using Blubber for your project
Wikimedia's Deployment pipeline pipeline project makes use of Blubber to run tests and publish images.
Blubber's background, philosophy, and implementation
Detailed Blubber User Guide

Developers

There is a short guide to contributing to Blubber for developers in the Blubber repository on Gerrit.