I am trying to create a maven-based buildkit image for the jenkins agent. If you create an image and run it as an agent, it takes infinite repetition. I think the image is built incorrectly, but it asks to inspect the Dockerfile.
FROM jenkins/inbound-agent:alpine as jnlp
FROM maven:3.6.3-jdk-11-slim as maven
RUN apt-get update && \
apt-get install -y \
git \
libfontconfig1 \
libfreetype6
FROM moby/buildkit
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"]
When only the maven agent is created without the "FROM moby/buildkit" statement, it runs without problems.
Updated answer with a full example:
Your Dockerfile doesn't have references to the maven image. If you need to have buildit in your final image you can install it by downloading from the GitHub or copying it from a docker image as you have for Jenkins agent.
I didn't test the docker file, but I hope you got the idea.
Update:
Per request in the comments, here is the version that might work for JDK8. You need to match all the components to have the same version to work: