layercake

command module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: MIT Imports: 35 Imported by: 0

README

Layercake

Build Status

Layercake is a command line tool for building complex Docker images. It can export layers from images and import them to other images easily. It's useful when you are trying to build some images with many dependencies.

Installation

You can install Layercake with one of the methods below:

Install Script
curl -sL https://github.com/tommy351/layercake/raw/master/install.sh | sh
Docker

https://hub.docker.com/r/tommy351/layercake/

docker run -it --rm \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  -v $(pwd):/src \
  -w /src \
  tommy351/layercake
go get
go get -d github.com/tommy351/layercake

Getting Started

Clone the examples.

git clone https://github.com/tommy351/layercake

Change to the example directory.

cd examples/hello_world

Build images.

layercake build

Configuration

You can specify the path of config files by adding --config option, or it looks for config files in one of the following paths from the current working directory:

  • layercake.yml
  • layercake.yaml

The following is an example of a config file.

# List all images to be built
# You don't have to sort the builds by their dependencies. Layercake resolves
# dependencies and builds images in order.
build:
  foo:
    # Base image (required)
    from: alpine
    # Image tags (optional)
    tags:
      - fooapp:tag
      - tommy351/fooapp:tag
    # Build arguments (optional)
    args:
      foo: bar
    # A list of images used for cache resolution (optional)
    cache_from:
      - alpine
    # Image labels (optional)
    labels:
      foo: bar
    # Build scripts (required)
    # Just like Dockerfile
    scripts:
      # You can use a string
      - RUN echo hello
      # Or a map
      - run: echo hello
      # The value can be any type
      - env:
          VERSION: 1.2.3
      # Import other layers from other builds
      - import: bar
  bar:
    from: busybox
    scripts:
      - run: echo bar

FAQ

Why not a plain Dockerfile?

Cache doesn't work when you try to modify one of lines in Dockerfile. You have to sort scripts to make sure the cache can do the best effort.

How about multi-stage builds?

It can be difficult to read if there are too many stages in Dockerfile. Also, you have to remember paths to copy from other stages.

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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