The Wayback Machine - https://web.archive.org/web/20191202231604/https://github.com/box-builder/box
Skip to content
A Next-Generation Builder for Docker Images
Go CSS HTML Shell Ruby JavaScript Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
builder builder/command/verbs.go: initialize label map Oct 27, 2017
cli-tests
copy copy: integration of github.com/box-builder/progress Mar 30, 2017
docs-theme
docs
fetcher builder,fetcher,layers: fix cmd/entrypoint semantics Apr 19, 2017
image image: remove a FIXME that is no longer necessary Apr 25, 2017
layers builder,fetcher,layers: fix cmd/entrypoint semantics Apr 19, 2017
logger Command interpreter integration with evaluator Mar 29, 2017
multi fetcher: always fetch the :latest tag if none specified Apr 12, 2017
pull pull: restore pull progress when tty is enabled Feb 14, 2017
release s/erikh/box-builder/g Mar 25, 2017
repl builder,repl,main.go: var support May 14, 2017
signal builder,layers,signal: Fix repl by passing Image context each statement Mar 4, 2017
tar builder,tar: fix a number of issues with the copy statement Jun 17, 2017
types
util util,builder: refactor utils packages into a unified one for broader … Feb 16, 2017
vendor vendor: associated vendoring updates Apr 12, 2017
.boxignore build.rb,.gitignore: generate box-builder oci images. Apr 10, 2017
.gitignore Theme style changed; logo added. Apr 13, 2017
CHANGELOG.md version 0.5.7 Oct 16, 2017
LICENSE.txt LICENSE.txt: rename the license file Feb 19, 2017
Makefile Makefile: add a task to update erikh.githubn.com/box May 13, 2017
README.md README.md: center README image Apr 13, 2017
box.rb box.rb: move to 1.9.2 for new builds Oct 31, 2017
checks.sh checks.sh: re-enable deadcode now that containers/image is gone Apr 14, 2017
dind Dockerfile,Makefile: add Docker in Docker Oct 12, 2016
docker-test.sh Makefile,build.rb,release: Convert to static build, move away from OS X Mar 6, 2017
install.sh version 0.5.7 Oct 16, 2017
install.sh.tmpl
main.go builder,repl,main.go: var support May 14, 2017
mkdocs.yml docs: Add download page May 13, 2017
mruby_config.rb Makefile,mruby_config.rb: tighten controls regarding mruby installati… Oct 21, 2016
portable.sh.tmpl
vendor.conf

README.md

Box: A Next-Generation Builder for Docker Images

Build Status Join the chat at https://gitter.im/box-builder/Lobby Go Report Card

Box is a builder for docker that gives you the power of mruby, a limited, embeddable ruby. It allows for notions of conditionals, loops, and data structures for use within your builder plan. If you've written a Dockerfile before, writing a box build plan is easy.

Box Build Plans are Programs

Exploit this! Use functions! Set variables and constants!

run this plan with:

GOLANG_VERSION=1.7.5 box <plan file>
from "ubuntu"

# this function will create a new layer running the command inside the
# function, installing the required package.
def install_package(pkg)
  run "apt-get install '#{pkg}' -y"
end

run "apt-get update"
install_package "curl" # `run "apt-get install curl -y"`

# get the local environment's setting for GOLANG_VERSION, and set it here:
go_version = getenv("GOLANG_VERSION")
run %Q[curl -sSL \
    https://storage.googleapis.com/golang/go#{go_version}.linux-amd64.tar.gz \
    | tar -xvz -C /usr/local]

Powered by mruby

Box uses the mruby programming language. It does this to get a solid language syntax, functions, variables and more. However, it is not a fully featured Ruby such as MRI and contains almost zero standard library functionality, allowing for only the basic types, and no I/O operations outside of the box DSL are permitted.

You can however:

  • Define classes, functions, variables and constants
  • Access the environment through the getenv box function (which is also omittable if you don't want people to use it)
  • Retrieve the contents of container files with read
  • import libraries (also written in mruby) to re-use common build plan components.

Tagging and Image Editing

You can tag images mid-plan to create multiple images, each subsets (or supersets, depending on how you look at it) of each other.

Additionally, you can use functions like after, skip, and flatten to manipulate images in ways you may not have considered:

from :ubuntu
skip do
  run "apt-get update"
  run "apt-get install curl -y"
  run "curl -sSL -O https://github.com/box-builder/box/releases/download/v0.4.2/box_0.4.2_amd64.deb"
  tag :downloaded
end

run "dpkg -i box*.deb"
after do
  flatten
  tag :installed
end

And more!

All the standard docker build commands such as user, env, and a few new ones:

  • with_user and inside temporarily scope commands to a specific user or working directory respectively, allowing you to avoid nasty patterns like cd foo && thing.
  • debug drop-in statement: drops you to a container in the middle of a build where you place the call.

REPL (Shell)

REPL is short for "read eval print loop" and is just a fancy way of saying this thing has readline support and a shell history. Check the thing out by invoking box repl or box shell.

Here's a video of the shell in action (click for more):

Box REPL

Install

Using the Homebrew Tap

brew tap box-builder/box && brew install box-builder/box/box

Advanced Use

The documentation is the best resource for learning the different verbs and functions. However, check out our own build plan for box for an example of how to use different predicates, functions, and verbs to get everything you need out of it.

Development Instructions

  • Requires: compiler, bison, flex, and libgpgme, libdevmapper, btrfs headers.
  • go get -d github.com/box-builder/box && cd $GOPATH/src/github.com/box-builder/box
  • To build on the host (create a dev environment):
    • make
  • To build a docker image for your dev environment (needed for test and release builds):
    • make build
  • If you have a dev environment:
    • make test
  • To do a release build:
    • VERSION=<version> make release
You can’t perform that action at this time.