40 lines
2.2 KiB
Docker
40 lines
2.2 KiB
Docker
# Trusted Jenkins delivery agent: inbound (WebSocket) agent + Docker CLI, Python,
|
|
# Ansible, pip-audit and Trivy. Rebuilding this image recreates every tool.
|
|
ARG AGENT_BASE=jenkins/inbound-agent:latest-jdk21@sha256:25a3704f7de4d3d0becc441f5683a227556658df1473865ee94c5232355678ab
|
|
# Docker CLI matching the host daemon (Docker Engine 29.8.2); the official CLI image ships buildx.
|
|
ARG DOCKER_CLI=docker:29.8.2-cli
|
|
|
|
FROM ${DOCKER_CLI} AS dockercli
|
|
|
|
FROM ${AGENT_BASE}
|
|
USER root
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends python3 python3-venv git openssh-client curl ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Docker client only (the daemon is the host's, via the mounted socket).
|
|
COPY --from=dockercli /usr/local/bin/docker /usr/local/bin/docker
|
|
COPY --from=dockercli /usr/local/libexec/docker/cli-plugins/docker-buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
|
|
|
# Trivy 0.69.3: a known-safe release after the March 2026 supply-chain incident
|
|
# (GHSA-69fq-xp46-6x23; 0.69.4-0.69.6 were malicious). Checksum from the release's checksums file.
|
|
ARG TRIVY_VERSION=0.69.3
|
|
ARG TRIVY_SHA256=1816b632dfe529869c740c0913e36bd1629cb7688bd5634f4a858c1d57c88b75
|
|
RUN curl -fsSLo /tmp/trivy.tgz "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" \
|
|
&& echo "${TRIVY_SHA256} /tmp/trivy.tgz" | sha256sum -c - \
|
|
&& tar -xzf /tmp/trivy.tgz -C /usr/local/bin trivy && rm /tmp/trivy.tgz
|
|
|
|
# Ansible and pip-audit in separate virtual environments (pinned top-level versions).
|
|
RUN python3 -m venv /opt/ansible-venv \
|
|
&& /opt/ansible-venv/bin/pip install --no-cache-dir ansible-core==2.19.15 \
|
|
&& /opt/ansible-venv/bin/ansible-galaxy collection install -p /usr/share/ansible/collections community.docker:==5.2.2 \
|
|
&& python3 -m venv /opt/pip-audit-venv \
|
|
&& /opt/pip-audit-venv/bin/pip install --no-cache-dir pip-audit==2.10.1
|
|
|
|
# Fail the image build if any tool is missing.
|
|
RUN for t in docker trivy python3 git ssh; do command -v "$t" >/dev/null || exit 1; done \
|
|
&& docker buildx version && trivy --version && /opt/ansible-venv/bin/ansible --version \
|
|
&& /opt/pip-audit-venv/bin/pip-audit --version
|
|
|
|
USER jenkins
|