Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haines/multidockerfile
Split multi-stage Dockerfiles into multiple files
https://github.com/haines/multidockerfile
docker dockerfile multi-stage
Last synced: 12 days ago
JSON representation
Split multi-stage Dockerfiles into multiple files
- Host: GitHub
- URL: https://github.com/haines/multidockerfile
- Owner: haines
- License: mit
- Archived: true
- Created: 2021-02-20T13:12:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-19T11:04:39.000Z (about 1 year ago)
- Last Synced: 2024-08-02T05:10:31.141Z (3 months ago)
- Topics: docker, dockerfile, multi-stage
- Language: Go
- Homepage:
- Size: 733 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# `multidockerfile`
`multidockerfile` is a command-line tool that allows you to split multi-stage Dockerfiles into multiple files.
## Background
[Multi-stage builds](https://docs.docker.com/develop/develop-images/multistage-build/) are a powerful way to optimize Dockerfiles, especially when combined with [`docker buildx bake`](https://github.com/docker/buildx/blob/master/docs/reference/buildx_bake.md) 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](https://github.com/haines/multidockerfile/releases).
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 fromGitHub (@haines)
```console
$ curl https://github.com/haines.gpg | gpg --import
```Keybase (haines)
```console
$ curl https://keybase.io/haines/pgp_keys.asc | gpg --import
```keys.openpgp.net ([email protected])
```console
$ gpg --keyserver keys.openpgp.org --recv-keys 6E225DD62262D98AAC77F9CDB16A6F178227A23E
```### With Docker
A Docker image is available for each release at [ghcr.io/haines/multidockerfile](https://ghcr.io/haines/multidockerfile).
## Usage
### `multidockerfile join ...`
Join multiple Dockerfiles into a single multi-stage Dockerfile.
#### Arguments
| Name | Description |
|-|-|
| ` ...` | Paths to the Dockerfiles to be joined. |#### Options
| Short | Long | Default | Description |
|-|-|-|-|
| `-o` | `--output` | `-` | Where to write the multi-stage Dockerfile (`-` for stdout). |#### Example
```dockerfile
# dockerfiles/one.dockerfileFROM alpine AS one
``````dockerfile
# dockerfiles/two.dockerfileFROM alpine AS two
``````console
$ multidockerfile join dockerfiles/*.dockerfile
FROM alpine AS one
FROM alpine AS two
```### `multidockerfile version`
Show the `multidockerfile` version information.
#### Example
```console
$ multidockerfile version
{
"Version": "0.1.0-dev",
"GitCommit": "20586c3eb00aad3dde1ca63eb47dcb14ae6372d5",
"Built": "2021-02-26T21:22:04Z",
"GoVersion": "go1.16",
"OS": "darwin",
"Arch": "amd64"
}
```