Awesome
dacc: docker-as-code compiler
Cache-efficient, sandboxed, builds as code.
- <ins>Native</ins> support with any Docker installation, no extra tools needed
- <ins>Infrastructure-as-code</ins> for docker images
- <ins>Cache-efficient</ins>: Represent any build graph in dacc
- <ins>Extend</ins>: merge, diff, and nested builds operations
A very parallel build (src) generated with dacc
Installation
dacc requires Docker.
npm install dacc
Getting Started - Hello World
Create a new project with the create-dacc
, which will create a new TypeScript project and install dacc in the directory provided.
npx create-dacc hello-dacc
Enter the newly created directory and run the build
cd hello-dacc && npm start
Examples
- Merging / Parallelism
- Diff Layers
- Generating protobuf definitions for this repository
- Building the Buildkit Frontend Image
- Multi-platform
- Nested builds
- Directory of additional examples
Merging / Parallelism
Docker images often have to install packages via a package manager. This might be specified in a single command RUN apk add git curl wget
. But when a new package is added, the entire cache is invalidated.
Instead, with dacc, you can install them in parallel and then merge the resulting filesystems. Adding or removing packages from the list won't invalidate the cache for the other packages.
import { cacheMount, State } from 'dacc'
async function main() {
const s = (await new State().from("alpine"))
const bins = ["git", "curl", "wget"]
s.merge(
s.parallel(
...bins.map(bin => (s: State) =>
s.run(`apk add ${bin}`).with(cacheMount("/var/cache/apk")))
),
)
s.image.run({
run: { command: "ls", args: bins.map(bin => `/usr/bin/${bin}`) },
})
}
void main()