Skip to main content

BuildKit

BuildKit In Heighliner

Heighliner uses Dagger which uses BuildKit to run concurrent, cache-efficient DAG workflow.

Use BuildKit Via Local Docker

If you have Docker installed in your local machine, then hln CLI will use it by default.

Use Remote BuildKit

If you don't want to run BuildKit locally, then you can use remote BuildKit instead.

You can run buildkit as a pod.

Save the following as buildkit.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: buildkitd
name: buildkitd
spec:
replicas: 1
selector:
matchLabels:
app: buildkitd
template:
metadata:
labels:
app: buildkitd
spec:
containers:
- name: buildkitd
image: moby/buildkit:v0.10.1
args:
- --addr
- unix:///run/buildkit/buildkitd.sock
- --addr
- tcp://0.0.0.0:1234
readinessProbe:
exec:
command:
- buildctl
- debug
- workers
initialDelaySeconds: 5
periodSeconds: 30
livenessProbe:
exec:
command:
- buildctl
- debug
- workers
initialDelaySeconds: 5
periodSeconds: 30
securityContext:
privileged: true
ports:
- containerPort: 1234
---
apiVersion: v1
kind: Service
metadata:
labels:
app: buildkitd
name: buildkitd
spec:
ports:
- port: 1234
protocol: TCP
selector:
app: buildkitd

Create the Buildkit service:

kubectl create -f buildkit.yaml

Make sure the buildkitd is running:

kubectl get deployment buildkitd

Output:

NAME        READY   UP-TO-DATE   AVAILABLE   AGE
buildkitd 1/1 1 1 4m26s

Forward local port 1234 to buildkitd:

kubectl port-forward service/buildkitd 1234:1234

Set env:

export BUILDKIT_HOST=tcp://127.0.0.1:1234

Then hln will talk to the remote BuildKit instead of local Docker daemon whenever you use hln features.

Refer to Dagger Customizing Buildkit documentation for more details.

heighliner