acbuild

module
v0.0.0-...-6911d3d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2015 License: Apache-2.0

README

acbuild

acbuild is a command line utility to build and modify App Container images (ACIs).

Rationale

Dockerfiles are powerful and feature useful concepts such as build layers, controlled build environment. At the same time, they lack flexibility (impossible to extend, re-use environment variables) and don't play nicely with the app spec and Linux toolchain (e.g. shell, makefiles)

This proposal introduces the concept of a command-line build tool, acbuild, that natively supports ACI builds and integrates well with shell, makefiles and other Unix tools.

Commands

acbuild will support several commands:

  • acbuild init in.aci creates an empty aci image in.aci with manifest filled up with auto generated stub contents

  • acbuild env -var="a=b" -var="c=d" -in=in.aci -out=out.aci adds environment variables to an image in.aci, outputs the result to out.aci

  • acbuild set-run /usr/local/bin/etcd -in=in.aci -out=out.aci sets a run command for the aci image in.aci, writing output to out.aci

  • acbuild set-label -a=key:val -a=key:val -in=in.aci -out=out.aci sets annotation label in manifest of in.aci and outputs the results to out.aci

  • acbuild add-image add.aci -in=in.aci -out=out.aci add contents of image add.aci to image in.aci and outputs the value to out.aci

  • acbuild add-dir /dir -in=in.aci -dir=/dir -out=out.aci add contents of directory /dir to image in.aci and outputs the result to out.aci

  • acbuild exec -in=in.aci -cmd=/var/run/cmd.run -out=out.aci unpacks image.aci, ask systemd-nspawn (either vendored with acbuild or provided by host OS) to execute command in image.aci's environment: /var/run/cmd.run, and add the results to the out.aci as a separate layer.

  • acbuild rm -in=in.aci sha512-abcdef... sha512-012345... modifies the manifest of in.aci and removes dependency references to sha512-abcdef... and sha512-012345...

  • acbuild squash -in=in.aci -layers=* -out=out.aci squashes all layers in in.aci and outputs out.aci as a result

  • acbuild push -user= -pass= in=in.aci url=registry-url -tag a:b pushes in.aci to the registry and add some tags to it

acbuild exec

acbuild exec executes the command using systemd-nspawn with the root filesystem of the image passed as a parameter.

acbuild exec -in=dbus.aci -out=built.aci "cd /build && ./configure && make && make install"

starts a build in the filesystem of the image dbus.aci

exec: modes of operation

The following modes of operation are possible

  • un-layered build with overlayfs support
  • un-layered build without overlayfs support
  • layered build with overlayfs support

In un-layered mode and without overlayfs support acbuild exec works as follows:

  • unpack in.aci to directory .acbuild/run/process-id()-sha512-short-hash(in.aci)
  • start systemd-nspawn running command
  • in case of successful execution convert the contents of a build directory to out.aci

In un-layered mode, and with overlayfs support acbuild exec works as follows:

  • unpack in.aci to .acbuild/cas/sha512-short-hash(in.aci)
  • mount it as a lower dir using overlayfs
  • mount a new directory as an overlayfs on top of it in .acbuild/run/process-id()-sha512-short-hash-upper(in.aci)
  • start systemd-nspawn running command, setting root directory as upper dir
  • in case of successful execution, take the results of upperdir and package it into out.aci

In layered mode and with overlayfs support acbuild exec works as follows:

  • unpack in.aci to .acbuild/cas/sha512-short-hash(in.aci)
  • mount it as a lower dir using overlayfs
  • mount a new directory as an overlayfs on top of it in .acbuild/run/process-id()-sha512-short-hash-upper(in.aci)
  • start systemd-nspawn running command passed by user setting root directory in upper dir
  • in case of successful execution, take the results of the workdir and convert it to an image, add this image as a dependency to aci, thus forming a layer, this mode is explicitly activated by acbuild exec --layer
exec: caching

Caching can be available as an explicit flag for the acbuild exec, giving users a choice to re-use the previous execution results for a command in cases when it makes sense, e.g when command execution results are idempotent.

acbuild exec -cache=true -in=in.aci "git clone --branch v219 --depth 1 git://anongit.freedesktop.org/systemd/systemd /tmp/out"

in case if -cache=true is set acbuild executes the following sequence:

  • check first if there’s an image in .acbuild/cache/hash(command line) and if it is present, reuse it instead of executing it and consider the operation completed
  • otherwise, unpack in.aci to some directory .acbuild/cache/hash(in.aci)
  • mount cas/in directory as a lower dir using overlayfs
  • mount a new directory as an overlayfs on top of it
  • start systemd-nspawn running command passed by user setting root directory as a cas/dir
  • in case of successful execution, take the results of the workdir and convert it to an image
  • associate this command git clone --branch v219 --depth 1 git://anongit.freedesktop.org/systemd/systemd /tmp/out with the newly created image in .acbuild/cache/hash(command line)

Note that in some cases caching does not make sense, e.g. for command rm -rf * would not do anything useful. We would leave the user to make this choice explicitly when writing a build script.

Modes of operation

acbuild should support several explicit modes of operation that can be selected by user:

  • Context-free: acbuild
  • Context via file or environment variable: acbuild -context
  • In-place updates: acbuild --patch
Context-free mode

Context-free mode is useful when taking some base image used as a start of the build process, and producing a modified and customized version of it, e.g.

acbuild add-dir /my-python-app -in=python-base.aci -out=my-app.aci

In context-free mode, input image and output image should be supplied as explicit command line flags: -in=in.aci -out=out.aci

Context via file

Context-dependent build context mode too, that will deduct -in and -out flags from the state explicitly initiated by user, e.g.:

acbuild -c init image.aci -from=python-base.aci

This command will execute the following steps:

  • create an image copying it from python-base.aci
  • create a .acbuild/context.json file with
    { 
      "type": "acbuild-context",
      "context": {
         "build-image": "image.aci",
       }
    }

and all the subsequent calls of the acbuild -c will re-use the parameters from the context, simulating a Docker-style build.

In-place updates

In-place updates can be useful when some aci should be modified on the fly e.g.

acbuild -p set-env HOST=$(hostname) -in image.aci

In place updates are activated by passing -p flag to the acbuild tool, in this case it will accept -in flag assuming the output to the same image

Implementation details

acbuild can be a simpler version of rkt - it will lack systemd and will vendor stage1.aci with patched systemd-nspawn (if <220) or re-use nspawn if the host OS provides it. In fact, rkt's build system can be migrated to acbuild.

Examples

build rkt stage1 using acbuild and buildroot

acbuild init image.aci
acbuild add buildroot.aci
acbuild add systemd-buildpack.aci   
acbuild exec "/configure && make && make strip-install" -out stage1.aci

build mongodb from official images

acbuild init mongodb.aci
acbuild add -dir mongodb-blabla.bin/ > out

use apt-get to install nginx

acbuild -in=in.aci -out=in.aci add-image aptitude.aci
acbuild -in=in.aci -out=out.aci exec apt-get -y install nginx

Directories

Path Synopsis
Godeps
_workspace/src/github.com/appc/spec/aci
Package aci contains various functions for working with App Container Images.
Package aci contains various functions for working with App Container Images.
_workspace/src/github.com/appc/spec/pkg/tarheader
Package tarheader contains a simple abstraction to accurately create tar.Headers on different operating systems.
Package tarheader contains a simple abstraction to accurately create tar.Headers on different operating systems.
_workspace/src/github.com/appc/spec/schema
Package schema provides definitions for the JSON schema of the different manifests in the App Container Specification.
Package schema provides definitions for the JSON schema of the different manifests in the App Container Specification.
_workspace/src/github.com/appc/spec/schema/types
Package types contains structs representing the various types in the app container specification.
Package types contains structs representing the various types in the app container specification.
_workspace/src/github.com/coreos/go-systemd/dbus
Integration with the systemd D-Bus API.
Integration with the systemd D-Bus API.
_workspace/src/github.com/coreos/rkt/pkg/aci
Package aci implements helper functions for working with ACIs
Package aci implements helper functions for working with ACIs
_workspace/src/github.com/coreos/rkt/pkg/lock
Package lock implements simple locking primitives on a regular file or directory using flock
Package lock implements simple locking primitives on a regular file or directory using flock
_workspace/src/github.com/coreos/rkt/pkg/tar
Package tar contains helper functions for working with tar files
Package tar contains helper functions for working with tar files
_workspace/src/github.com/coreos/rkt/store
Package store implements a content-addressable-store on disk.
Package store implements a content-addressable-store on disk.
_workspace/src/github.com/cznic/b
Package b implements the B+tree flavor of a BTree.
Package b implements the B+tree flavor of a BTree.
_workspace/src/github.com/cznic/bufs
Package bufs implements a simple buffer cache.
Package bufs implements a simple buffer cache.
_workspace/src/github.com/cznic/exp/lldb
Package lldb (WIP) implements a low level database engine.
Package lldb (WIP) implements a low level database engine.
_workspace/src/github.com/cznic/fileutil
Package fileutil collects some file utility functions.
Package fileutil collects some file utility functions.
_workspace/src/github.com/cznic/fileutil/falloc
WIP: Package falloc provides allocation/deallocation of space within a file/store (WIP, unstable API).
WIP: Package falloc provides allocation/deallocation of space within a file/store (WIP, unstable API).
_workspace/src/github.com/cznic/fileutil/hdb
WIP: Package hdb provides a "handle"/value DB like store, but actually it's closer to the model of a process's virtual memory and its alloc, free and move methods.
WIP: Package hdb provides a "handle"/value DB like store, but actually it's closer to the model of a process's virtual memory and its alloc, free and move methods.
_workspace/src/github.com/cznic/fileutil/storage
WIP: Package storage defines and implements storage providers and store accessors.
WIP: Package storage defines and implements storage providers and store accessors.
_workspace/src/github.com/cznic/mathutil
Package mathutil provides utilities supplementing the standard 'math' and 'math/rand' packages.
Package mathutil provides utilities supplementing the standard 'math' and 'math/rand' packages.
_workspace/src/github.com/cznic/mathutil/mersenne
Package mersenne collects utilities related to Mersenne numbers[1] and/or some of their properties.
Package mersenne collects utilities related to Mersenne numbers[1] and/or some of their properties.
_workspace/src/github.com/cznic/ql
Package ql is a pure Go embedded (S)QL database.
Package ql is a pure Go embedded (S)QL database.
_workspace/src/github.com/cznic/ql/design
Package design describes some of the data structures used in QL.
Package design describes some of the data structures used in QL.
_workspace/src/github.com/cznic/ql/driver
Package driver registers a QL sql/driver named "ql" and a memory driver named "ql-mem".
Package driver registers a QL sql/driver named "ql" and a memory driver named "ql-mem".
_workspace/src/github.com/cznic/ql/ql command
Command ql is a utility to explore a database, prototype a schema or test drive a query, etc.
Command ql is a utility to explore a database, prototype a schema or test drive a query, etc.
_workspace/src/github.com/cznic/sortutil
Package sortutil provides utilities supplementing the standard 'sort' package.
Package sortutil provides utilities supplementing the standard 'sort' package.
_workspace/src/github.com/cznic/strutil
Package strutil collects utils supplemental to the standard strings package.
Package strutil collects utils supplemental to the standard strings package.
_workspace/src/github.com/cznic/zappy
Package zappy implements the zappy block-based compression format.
Package zappy implements the zappy block-based compression format.
_workspace/src/github.com/godbus/dbus
Package dbus implements bindings to the D-Bus message bus system.
Package dbus implements bindings to the D-Bus message bus system.
_workspace/src/github.com/godbus/dbus/introspect
Package introspect provides some utilities for dealing with the DBus introspection format.
Package introspect provides some utilities for dealing with the DBus introspection format.
_workspace/src/github.com/godbus/dbus/prop
Package prop provides the Properties struct which can be used to implement org.freedesktop.DBus.Properties.
Package prop provides the Properties struct which can be used to implement org.freedesktop.DBus.Properties.
_workspace/src/github.com/golang/protobuf/proto
Package proto converts data structures to and from the wire format of protocol buffers.
Package proto converts data structures to and from the wire format of protocol buffers.
_workspace/src/github.com/kardianos/osext
Extensions to the standard "os" package.
Extensions to the standard "os" package.
_workspace/src/github.com/opencontainers/runc/libcontainer
Libcontainer provides a native Go implementation for creating containers with namespaces, cgroups, capabilities, and filesystem access controls.
Libcontainer provides a native Go implementation for creating containers with namespaces, cgroups, capabilities, and filesystem access controls.
_workspace/src/github.com/opencontainers/runc/libcontainer/integration
integration is used for integration testing of libcontainer
integration is used for integration testing of libcontainer
_workspace/src/github.com/opencontainers/runc/libcontainer/netlink
Packet netlink provide access to low level Netlink sockets and messages.
Packet netlink provide access to low level Netlink sockets and messages.
_workspace/src/github.com/opencontainers/runc/libcontainer/seccomp
Package seccomp provides native seccomp ( https://www.kernel.org/doc/Documentation/prctl/seccomp_filter.txt ) support for go.
Package seccomp provides native seccomp ( https://www.kernel.org/doc/Documentation/prctl/seccomp_filter.txt ) support for go.
_workspace/src/github.com/petar/GoLLRB/llrb
A Left-Leaning Red-Black (LLRB) implementation of 2-3 balanced binary search trees, based on the following work:
A Left-Leaning Red-Black (LLRB) implementation of 2-3 balanced binary search trees, based on the following work:
_workspace/src/github.com/satori/go.uuid
Package uuid provides implementation of Universally Unique Identifier (UUID).
Package uuid provides implementation of Universally Unique Identifier (UUID).
_workspace/src/github.com/spf13/cobra
Package cobra is a commander providing a simple interface to create powerful modern CLI interfaces.
Package cobra is a commander providing a simple interface to create powerful modern CLI interfaces.
_workspace/src/github.com/spf13/pflag
pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
_workspace/src/github.com/stretchr/objx
objx - Go package for dealing with maps, slices, JSON and other data.
objx - Go package for dealing with maps, slices, JSON and other data.
_workspace/src/github.com/stretchr/testify
Package testify is a set of packages that provide many tools for testifying that your code will behave as you intend.
Package testify is a set of packages that provide many tools for testifying that your code will behave as you intend.
_workspace/src/github.com/stretchr/testify/assert
Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
_workspace/src/github.com/stretchr/testify/http
A set of tools to make testing http activity using the Go testing system easier.
A set of tools to make testing http activity using the Go testing system easier.
_workspace/src/github.com/stretchr/testify/mock
Provides a system by which it is possible to mock your objects and verify calls are happening as expected.
Provides a system by which it is possible to mock your objects and verify calls are happening as expected.
_workspace/src/github.com/stretchr/testify/require
Alternative testing tools which stop test execution if test failed.
Alternative testing tools which stop test execution if test failed.
_workspace/src/github.com/stretchr/testify/suite
The suite package contains logic for creating testing suite structs and running the methods on those structs as tests.
The suite package contains logic for creating testing suite structs and running the methods on those structs as tests.
_workspace/src/github.com/syndtr/gocapability/capability
Package capability provides utilities for manipulating POSIX capabilities.
Package capability provides utilities for manipulating POSIX capabilities.
_workspace/src/golang.org/x/crypto/cast5
Package cast5 implements CAST5, as defined in RFC 2144.
Package cast5 implements CAST5, as defined in RFC 2144.
_workspace/src/golang.org/x/crypto/openpgp
Package openpgp implements high level operations on OpenPGP messages.
Package openpgp implements high level operations on OpenPGP messages.
_workspace/src/golang.org/x/crypto/openpgp/armor
Package armor implements OpenPGP ASCII Armor, see RFC 4880.
Package armor implements OpenPGP ASCII Armor, see RFC 4880.
_workspace/src/golang.org/x/crypto/openpgp/clearsign
Package clearsign generates and processes OpenPGP, clear-signed data.
Package clearsign generates and processes OpenPGP, clear-signed data.
_workspace/src/golang.org/x/crypto/openpgp/elgamal
Package elgamal implements ElGamal encryption, suitable for OpenPGP, as specified in "A Public-Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms," IEEE Transactions on Information Theory, v.
Package elgamal implements ElGamal encryption, suitable for OpenPGP, as specified in "A Public-Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms," IEEE Transactions on Information Theory, v.
_workspace/src/golang.org/x/crypto/openpgp/errors
Package errors contains common error types for the OpenPGP packages.
Package errors contains common error types for the OpenPGP packages.
_workspace/src/golang.org/x/crypto/openpgp/packet
Package packet implements parsing and serialization of OpenPGP packets, as specified in RFC 4880.
Package packet implements parsing and serialization of OpenPGP packets, as specified in RFC 4880.
_workspace/src/golang.org/x/crypto/openpgp/s2k
Package s2k implements the various OpenPGP string-to-key transforms as specified in RFC 4800 section 3.7.1.
Package s2k implements the various OpenPGP string-to-key transforms as specified in RFC 4800 section 3.7.1.
_workspace/src/speter.net/go/exp/math/dec/inf
Package inf (type inf.Dec) implements "infinite-precision" decimal arithmetic.
Package inf (type inf.Dec) implements "infinite-precision" decimal arithmetic.
cmd
acb command
Package dtree allows for traversing and manipulating the dependency trees of ACI images.
Package dtree allows for traversing and manipulating the dependency trees of ACI images.
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL