Feature/issue 24 delivery #27
@@ -0,0 +1,3 @@
|
|||||||
|
# Secrets and host-specific values stay on the Droplet
|
||||||
|
agent.secrets.env
|
||||||
|
.env
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Trusted Jenkins delivery agent for Chapter 6.
|
||||||
|
# Build context is the repository root (see agent/compose.yaml).
|
||||||
|
FROM jenkins/inbound-agent:latest-jdk21
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
# Python 3 + venv for tests, pip-audit and Ansible; curl for checks
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends python3 python3-venv python3-pip ca-certificates curl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Docker CLI + buildx plugin (client only; the daemon is the host's, via the mounted socket)
|
||||||
|
COPY --from=docker:cli /usr/local/bin/docker /usr/local/bin/docker
|
||||||
|
COPY --from=docker/buildx-bin /buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
||||||
|
|
||||||
|
# Trivy scanner (image vulnerabilities + secret scanning)
|
||||||
|
COPY --from=aquasec/trivy:latest /usr/local/bin/trivy /usr/local/bin/trivy
|
||||||
|
|
||||||
|
# Ansible in its own virtual environment, plus the community.docker collection
|
||||||
|
ENV ANSIBLE_COLLECTIONS_PATH=/opt/ansible-collections
|
||||||
|
COPY ansible/requirements.yml /tmp/ansible-requirements.yml
|
||||||
|
RUN python3 -m venv /opt/ansible-venv \
|
||||||
|
&& /opt/ansible-venv/bin/pip install --no-cache-dir ansible-core \
|
||||||
|
&& /opt/ansible-venv/bin/ansible-galaxy collection install -r /tmp/ansible-requirements.yml -p /opt/ansible-collections \
|
||||||
|
&& rm /tmp/ansible-requirements.yml
|
||||||
|
|
||||||
|
# pip-audit in a separate tools venv
|
||||||
|
RUN python3 -m venv /opt/tools-venv \
|
||||||
|
&& /opt/tools-venv/bin/pip install --no-cache-dir pip-audit
|
||||||
|
|
||||||
|
USER jenkins
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# Copy to agent.secrets.env on the Droplet (chmod 600). Never commit the real file.
|
||||||
|
JENKINS_SECRET=PASTE_FROM_JENKINS_NODE_PAGE
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Trusted delivery agent. Connects to the existing Jenkins controller over the
|
||||||
|
# internal gitea-net network (WebSocket), so no new port is published.
|
||||||
|
services:
|
||||||
|
jenkins-agent:
|
||||||
|
build:
|
||||||
|
context: ..
|
||||||
|
dockerfile: agent/Dockerfile
|
||||||
|
image: ssw590/jenkins-delivery-agent:1
|
||||||
|
container_name: jenkins-agent
|
||||||
|
restart: unless-stopped
|
||||||
|
env_file: [agent.secrets.env] # JENKINS_SECRET only; not in Git
|
||||||
|
environment:
|
||||||
|
JENKINS_URL: "http://jenkins:8080/"
|
||||||
|
JENKINS_AGENT_NAME: "delivery-agent"
|
||||||
|
JENKINS_WEB_SOCKET: "true"
|
||||||
|
JENKINS_AGENT_WORKDIR: "/home/jenkins/agent"
|
||||||
|
# Host Docker socket: needed to build/push images. This is effectively root
|
||||||
|
# on the Droplet, so only reviewed main-branch delivery jobs may use this agent.
|
||||||
|
group_add: ["${DOCKER_GID:?set DOCKER_GID in .env}"]
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- agent_home:/home/jenkins # workspace, known_hosts, registry login
|
||||||
|
networks: [gitea-net]
|
||||||
|
|
||||||
|
networks:
|
||||||
|
gitea-net:
|
||||||
|
external: true
|
||||||
|
name: gitea-net
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
agent_home:
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Print tool versions inside the agent. From the repo root on the Droplet:
|
||||||
|
# docker exec -i jenkins-agent sh -s < agent/versions.sh
|
||||||
|
echo "== java"; java -version 2>&1 | head -1
|
||||||
|
echo "== python"; python3 --version
|
||||||
|
echo "== docker"; docker version --format 'client {{.Client.Version}} / server {{.Server.Version}}'
|
||||||
|
echo "== buildx"; docker buildx version
|
||||||
|
echo "== trivy"; trivy --version | head -1
|
||||||
|
echo "== pip-audit"; /opt/tools-venv/bin/pip-audit --version
|
||||||
|
echo "== ansible"; /opt/ansible-venv/bin/ansible --version | head -3
|
||||||
|
echo "== collections"; /opt/ansible-venv/bin/ansible-galaxy collection list community.docker 2>/dev/null | tail -2
|
||||||
|
echo "== os"; . /etc/os-release; echo "$PRETTY_NAME $(uname -m)"
|
||||||
Reference in New Issue
Block a user