multidockerfile

module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: MIT

README

multidockerfile

multidockerfile is a command-line tool that allows you to split multi-stage Dockerfiles into multiple files.

Background

Multi-stage builds are a powerful way to optimize Dockerfiles, especially when combined with docker buildx bake to build multiple images in parallel. However, Docker requires that all stages are defined in a single Dockerfile, which can become difficult to navigate as it grows.

With multidockerfile, you can split the Dockerfile up, and recombine it with multidockerfile join before building the images.

multidockerfile parses the individual Dockerfiles looking for the FROM and COPY --from instructions that create dependencies between stages. The combined Dockerfile is sorted so that stages with dependencies appear after the stages on which they depend.

Installation

From binary releases

Pre-built binaries are available for each release. You can download the correct version for your operating system, make it executable with chmod +x, and either execute it directly or put it on your path.

SHA-256 checksums and GPG signatures are available to verify integrity. My GPG public key can be obtained from

GitHub (@haines)
$ curl https://github.com/haines.gpg | gpg --import
Keybase (haines)
$ curl https://keybase.io/haines/pgp_keys.asc | gpg --import
keys.openpgp.net (andrew@haines.org.nz)
$ gpg --keyserver keys.openpgp.org --recv-keys 6E225DD62262D98AAC77F9CDB16A6F178227A23E
With Docker

A Docker image is available for each release at ghcr.io/haines/multidockerfile.

Usage

multidockerfile join <inputs> ...

Join multiple Dockerfiles into a single multi-stage Dockerfile.

Arguments
Name Description
<inputs> ... Paths to the Dockerfiles to be joined.
Options
Short Long Default Description
-o --output - Where to write the multi-stage Dockerfile (- for stdout).
Example
# dockerfiles/one.dockerfile

FROM alpine AS one
# dockerfiles/two.dockerfile

FROM alpine AS two
$ multidockerfile join dockerfiles/*.dockerfile
FROM alpine AS one
FROM alpine AS two
multidockerfile version

Show the multidockerfile version information.

Example
$ multidockerfile version
{
  "Version": "0.1.0-dev",
  "GitCommit": "20586c3eb00aad3dde1ca63eb47dcb14ae6372d5",
  "Built": "2021-02-26T21:22:04Z",
  "GoVersion": "go1.16",
  "OS": "darwin",
  "Arch": "amd64"
}

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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