An image for the Jenkins agent buildkit was created using the Dockerfile below.
FROM jenkins/inbound-agent:alpine as jnlp
FROM moby/buildkit as buildkit
USER root
RUN apk update \
&& apk upgrade \
&& apk add --update openjdk11 tzdata curl unzip bash \
&& rm -rf /var/cache/apk/*
COPY --from=jnlp /usr/local/bin/jenkins-agent /usr/local/bin/jenkins-agent
COPY --from=jnlp /usr/share/jenkins/agent.jar /usr/share/jenkins/agent.jar
ENTRYPOINT ["/usr/local/bin/jenkins-agent"]
The image runs normally as a Kubernetes pod. However, when I try to build the image using buildkit in the pod, an error occurs. I don't know what the problem is.
+ buildctl build --frontend dockerfile.v0 --local 'context=.' --local 'dockerfile=.' --output 'type=image,name=docker.io/username/image'
error: listing workers for Build: failed to list workers: Unavailable: connection error: desc = "transport: error while dialing: dial unix /run/buildkit/buildkitd.sock: connect: no such file or directory"
When executing the above command, the following error occurs.
The buildkit was registered in the Jenkins helm chart as follows.
builkit:
podName: buildkit
customJenkinsLabels: buildkit
image: "agent-buildkit"
tag: "1.0"
alwaysPullImage: true
ENTRYPOINTin your dockerfile runningjenkins-agentbut do nothing with buildkit. You need to check what theENTRYPOINTin the originalmoby/buildkitimage and create a custom script that will do both:buildkitdaemonjenkins-agentIt's not ideal when you have multiple processes in your docker image, so it would be nice to add child management to your script (catch signals with trap and gracefully shutdown both jenkins and buildkit).