Blubber/Download

From Wikitech
Jump to navigation Jump to search

Blubber as a BuildKit frontend

Blubber is now implemented as a BuildKit frontend that can be used directly with docker build, docker buildx or buildctl.

Using Blubber with docker build or docker buildx

To build an image from your blubber.yaml using Docker build tools, simply add the correct syntax directive at the top of the file that references the image name and version that you're using. Be sure to check for the latest version/tag on docker-registry.wikimedia.org to ensure compatibility with WMF CI as we'll likely be using the latest release.

# syntax=docker-registry.wikimedia.org/repos/releng/blubber:v0.12.1
version: v4
variants:
  build:
    base: docker-registry.wikimedia.org/golang1.18
    lives:
      in: /src
    builders:
     - custom:
         requirements: [Makefile, src/]
         command: [make]
  test:
    copies:
      - from: build
        source: /src/my-program
        destination: ./
    entrypoint: [./my-program]

That's it. Now your blubber.yaml can be used directly with Docker build tools!

$ docker build --target test -f blubber.yaml .
$ docker buildx build --target test -f blubber.yaml --platform=linux/amd64,linux/arm64 .

Using Blubber with buildctl

Note that buildctl requires a running instance of buildkitd, so we recommend using Docker tools for most development use cases. However, buildctl is what we use in CI, so the closest thing to that locally would be the following.

docker run -d --name buildkitd --privileged docker-registry.wikimedia.org/repos/releng/buildkit:wmf-v0.10-1
export BUILDKIT_HOST=docker-container://buildkitd
buildctl build --frontend=gateway.v0 \
  --opt source=docker-registry.wikimedia.org/repos/releng/blubber::v0.12.1 \
  --local context=. \
  --local dockerfile=. \
  --opt filename=blubber.yaml \
  --opt target=test

CLI binary

Using Go tools

go install gitlab.wikimedia.org/repos/releng/blubber/cmd/blubber@latest

(Be sure that $GOPATH/bin is in your PATH. If the environment variable is unset, the default is returned by go env GOPATH.)

Installing from source

See CONTRIBUTING.md in the Blubber repo.

Further reading

Tutorials

Now that you have Blubber installed, try your hand at one of the tutorials.