Home

Awesome

dacc: docker-as-code compiler

Cache-efficient, sandboxed, builds as code.

A very parallel build 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

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()