Code Monkey home page Code Monkey logo

buildkit-wrapper's Introduction

BuildKit wrapper

This wrapper uses internal buildkit API and enables more customised build process than offered by docker build. It is using containerd for storing outputs (images). Such approach allows importing and exporting contents of build cache layers, which can be useful on distributed build systems.

Usage:

Start buildkit container:
docker run -d --rm --privileged \
  -v /run/buildkit:/run/buildkit
  -v /var/lib/buildkit:/var/lib/buildkit \
  -v /run/containerd:/run/containerd \
  -v /var/lib/containerd:/var/lib/containerd \
  -v /tmp:/tmp \
  --name buildkit moby/buildkit:latest \
  --oci-worker=false --containerd-worker=true
Download and extract buildkit-build

The binary version works on Linux/AMD64 only.

docker create --name buildkit-wrapper korekontrol/buildkit-wrapper
docker cp buildkit-wrapper:/buildkit-build .
docker rm buildkit-wrapper
Build an image

Setup buildkit endpoint configuration:

export BUILDKIT_HOST=tcp://0.0.0.0:1234

For import or export cache, add environmental variables:

export BUILDKIT_LOCAL_CACHE_IMPORT=/tmp/docker-layers
export BUILDKIT_LOCAL_CACHE_EXPORT=/tmp/docker-layers

Run the build:

./buildkit-build -t <image_name> (...)

This process is executed using standalone buildkit, running in a container. It is not the same as building container using buildkit bundled in docker. Note that resulting container will be persisted in local containerd image repository, so it will not be available to docker. If you want to use it in docker, you need to export/import image.

Export containerd image into docker
ctr --namespace buildkit images export - <image_name> \
  | docker image import - <image_name>

Syntax

The syntax of ./buildkit-build should be the same as syntax of docker build. Currently, only limited set of docker build options is supported:

Option Description
--file <filename> (required) Path to Dockerfile
--tag <value> (required) Resulting image name/tag
--build-arg <name>=<value> Add build argument value
--label <name>=<value> Add label value
--target <value> Target name (inside Dockerfile)
--progress <value> plain, tty or auto

Credits

Adapted by Marek Obuchowicz from KoreKontrol. Repository is a fork of moby/buildkit and is based on examples provided there.

License

APACHE

buildkit-wrapper's People

Contributors

aaronlehmann avatar abailly avatar akihirosuda avatar allencloud avatar antaress avatar arm64b avatar asottile avatar calavera avatar chendave avatar cpuguy83 avatar crosbymichael avatar dmcgowan avatar dnephin avatar fuweid avatar hinshun avatar ijc avatar jessfraz avatar kunalkushwaha avatar liubin avatar lk4d4 avatar m-hu avatar marek-obuchowicz avatar quasilyte avatar seemethere avatar thajeztah avatar tonistiigi avatar trusch avatar xulike666 avatar yongtang avatar yui-knk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.