jenkins-podman/Dockerfile

57 lines
1.9 KiB
Docker
Raw Normal View History

2022-01-25 11:16:28 +00:00
ARG BASE="4.11.2-4-alpine-jdk17-preview"
2022-01-13 11:41:17 +00:00
FROM jenkins/inbound-agent:${BASE}
2022-06-27 17:16:02 +00:00
ARG USER=jenkins
2022-01-13 11:41:17 +00:00
USER root
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
2022-02-14 11:53:25 +00:00
&& apk upgrade -U --available --no-cache \
&& apk add --no-cache \
tini \
2022-01-13 11:41:17 +00:00
make \
2022-02-03 18:29:47 +00:00
yq \
2022-06-27 17:16:02 +00:00
strace \
2022-01-13 11:41:17 +00:00
fuse-overlayfs \
podman \
buildah \
aws-cli \
trivy
2022-01-14 00:23:18 +00:00
# Trivy html template
ADD --chown=jenkins:jenkins html.tpl /home/jenkins
# Rootless podman
2022-06-27 17:16:02 +00:00
RUN mkdir -p /home/$USER/.local/share/containers && \
chown $USER:$USER -R /home/$USER
ADD conf/containers.conf conf/registries.conf conf/storage.conf /etc/containers/
ADD --chown=$USER:$USER conf/podman-containers.conf /home/$USER/.config/containers/containers.conf
2022-01-13 11:41:17 +00:00
2022-06-27 17:16:02 +00:00
RUN mkdir -p /var/lib/shared/overlay-images /var/lib/shared/overlay-layers \
2022-01-13 11:41:17 +00:00
/var/lib/shared/vfs-images /var/lib/shared/vfs-layers && \
touch /var/lib/shared/overlay-images/images.lock /var/lib/shared/overlay-layers/layers.lock \
2022-01-14 00:23:18 +00:00
/var/lib/shared/vfs-images/images.lock /var/lib/shared/vfs-layers/layers.lock && \
2022-06-27 17:16:02 +00:00
mkdir /tmp/podman-run-1000 && chown $USER:$USER /tmp/podman-run-1000 && chmod 700 /tmp/podman-run-1000 && \
echo -e "$USER:1:999\n$USER:1001:64535" > /etc/subuid && \
echo -e "$USER:1:999\n$USER:1001:64535" > /etc/subgid
#setcap cap_setuid=ep /usr/bin/newuidmap && \
#setcap cap_setgid=ep /usr/bin/newgidmap && \
RUN mkdir /workspace && \
cd /usr/bin && ln -s podman docker
2022-01-13 11:41:17 +00:00
# Patch jenkins-agent to launch podman service
RUN sed -i -e 's/exec \$JAVA_BIN/podman system service -t0\&\n exec \$JAVA_BIN/' /usr/local/bin/jenkins-agent
2022-01-14 00:23:18 +00:00
ENV XDG_RUNTIME_DIR=/tmp/podman-run-1000
2022-06-27 17:16:02 +00:00
ENV _CONTAINERS_USERNS_CONFIGURED=""
2022-01-13 13:56:54 +00:00
ENV BUILDAH_ISOLATION=chroot
2022-01-14 00:23:18 +00:00
ENV TRIVY_TEMPLATE="@/home/jenkins/html.tpl"
USER jenkins
2022-01-13 11:41:17 +00:00
# Allow container layers to be stored in PVCs
VOLUME /home/jenkins/.local/share/containers
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/jenkins-agent"]