commit 3d3d75df38391b61bd3f37b8357d150d2b4799d1
parent 60cd4aa5d4f2e9988cd54c193804044a21aceebd
Author: Andreas Gruhler <agruhl@gmx.ch>
Date: Sun, 10 Aug 2025 11:23:06 +0200
feat(jenkins-agent): build with args
Diffstat:
2 files changed, 15 insertions(+), 37 deletions(-)
diff --git a/Jenkinsfile b/Jenkinsfile
@@ -5,7 +5,11 @@ def buildahpush = new BuildahPush(this)
node('podman'){
checkout scm
- buildahbud.execute('docker/docker-jenkins-inbound-agent', 'jenkins-inbound-agent', 'arm64/v8', '3327.v868139a_d00e0')
+ buildahbud.execute(
+ [uid: 1312, gid: 1312],
+ 'docker/docker-jenkins-inbound-agent',
+ 'jenkins-inbound-agent',
+ '3327.v868139a_d00e0')
buildahpush.execute('jenkins-inbound-agent', '3327.v868139a_d00e0')
//gitleaks()
diff --git a/docker/docker-jenkins-inbound-agent/Dockerfile b/docker/docker-jenkins-inbound-agent/Dockerfile
@@ -34,29 +34,18 @@ ARG user=jenkins
ARG group=jenkins
ARG uid=1000
ARG gid=1000
-
-RUN addgroup -g "${gid}" "${group}" \
- && adduser -h /home/"${user}" -u "${uid}" -G "${group}" -D "${user}" || echo "user ${user} already exists."
-
ARG AGENT_WORKDIR=/home/"${user}"/agent
+RUN addgroup -g "${gid}" "${group}"
+RUN adduser -h /home/"${user}" -u "${uid}" -G "${group}" -D "${user}"
+
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
ENV TZ=Etc/UTC
-RUN apk add openjdk24 --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing
-
RUN apk update && apk add --no-cache \
- curl \
- bash \
- git \
- git-lfs \
- musl-locales \
- openssh-client \
- openssl \
- procps \
- tzdata \
- tzdata-utils \
- && rm -rf /tmp/*.apk /tmp/gcc /tmp/gcc-libs.tar* /tmp/libz /tmp/libz.tar.xz /var/cache/apk/*
+ curl bash git git-lfs musl-locales \
+ openssh-client openssl procps tzdata tzdata-utils
+RUN apk add openjdk24 --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing
# Download Jenkins remoting agent
ARG VERSION=3327.v868139a_d00e0
@@ -72,20 +61,10 @@ VOLUME /home/"${user}"/.jenkins
VOLUME "${AGENT_WORKDIR}"
WORKDIR /home/"${user}"
ENV user=${user}
-LABEL \
- org.opencontainers.image.vendor="Jenkins project" \
- org.opencontainers.image.title="Official Jenkins Agent Base Docker image" \
- org.opencontainers.image.description="This is a base image, which provides the Jenkins agent executable (agent.jar)" \
- org.opencontainers.image.version="${VERSION}" \
- org.opencontainers.image.url="https://www.jenkins.io/" \
- org.opencontainers.image.source="https://github.com/jenkinsci/docker-agent" \
- org.opencontainers.image.licenses="MIT"
## Inbound Agent image target
FROM agent AS inbound-agent
-ARG user=jenkins
-
USER root
# Install Docker client
@@ -106,16 +85,20 @@ RUN curl -fsSL https://github.com/docker/compose/releases/download/$DOCKER_COMPO
#
# netavark is a required dependency to run `buildah bud`.
RUN apk add --no-cache buildah netavark fuse-overlayfs fuse
+
# Set up environment variables to note that this is not starting with user
# namespace and default to isolate the filesystem with chroot.
# https://developers.redhat.com/blog/2019/08/14/best-practices-for-running-buildah-in-a-container
ENV _BUILDAH_STARTED_IN_USERNS="" BUILDAH_ISOLATION=chroot
+
# https://docs.podman.io/en/latest/markdown/podman.1.html#note-unsupported-file-systems-in-rootless-mode
RUN sed -i 's/#mount_program/mount_program/' /etc/containers/storage.conf
+
# fuse: device not found, try 'modprobe fuse' first
# https://github.com/containers/podman/blob/main/troubleshooting.md#24-podman-container-images-fail-with-fuse-device-not-found-when-run
RUN mkdir -p /etc/modules.load.d
RUN echo fuse > /etc/modules.load.d/fuse.conf
+
# Configure missing subuid/subgids for rootless podman builds
# https://docs.podman.io/en/latest/markdown/podman.1.html#rootless-mode
RUN echo jenkins:10000:65536 >> /etc/subuid
@@ -123,13 +106,4 @@ RUN echo jenkins:10000:65536 >> /etc/subgid
USER ${user}
-LABEL \
- org.opencontainers.image.vendor="Jenkins project" \
- org.opencontainers.image.title="Official Jenkins Agent Base Docker image" \
- org.opencontainers.image.description="This is an image for Jenkins agents using TCP or WebSockets to establish inbound connection to the Jenkins controller" \
- org.opencontainers.image.version="${VERSION}" \
- org.opencontainers.image.url="https://www.jenkins.io/" \
- org.opencontainers.image.source="https://github.com/jenkinsci/docker-agent" \
- org.opencontainers.image.licenses="MIT"
-
CMD ["/bin/sh", "-c", "java -jar /usr/share/jenkins/agent.jar ${REMOTING_OPTS} $@"]