1- FROM quay .io/podman/stable:v5.6
1+ FROM docker .io/ppodgorsek/ansible-awx-ee:24.6.1.4
22
33LABEL authors="Paul Podgorsek"
44LABEL description="An agent for Azure Pipelines, with Ansible, git, Helm + kubectl, Java, Maven, .Net, Podman (Docker) + Buildah, PostgreSQL, Python 3 and Terraform enabled."
55
6+ ENV AGENT_GROUP_ID="1000"
7+ ENV AGENT_USER_ID="1000"
68ENV AGENT_USER_NAME="podman"
79ENV AGENT_WORK_DIR="/opt/pipeline-agent"
810
@@ -11,14 +13,7 @@ ENV AZURE_DEVOPS_AGENT_POOL="Default"
1113ENV AZURE_DEVOPS_AGENT_NAME=""
1214ENV AZURE_DEVOPS_AGENT_VERSION="4.264.2"
1315
14- ENV ANSIBLE_COLLECTION_AWS_VERSION="10.1.2"
15- ENV ANSIBLE_COLLECTION_AZURE_VERSION="v3.11.0"
16- ENV ANSIBLE_COLLECTION_GCP_VERSION="v1.10.2"
1716ENV DOTNET_VERSION="10.0"
18- ENV HELM_VERSION="v3.19.0"
19- ENV JAVA_VERSION="21"
20- ENV POSTGRESQL_VERSION="18"
21- ENV TERRAFORM_VERSION="1.13.5"
2217
2318# Agent capabilities
2419ENV ansible="enabled"
@@ -31,40 +26,72 @@ ENV maven="enabled"
3126ENV postgresql="enabled"
3227ENV terraform="enabled"
3328
29+ USER root
30+
3431# Don't include container-selinux and remove directories used by DNF that are just taking up space.
3532RUN dnf upgrade -y > /dev/null \
33+ && dnf reinstall -y shadow-utils \
3634 && dnf install -y \
3735 --exclude container-selinux \
3836 automake \
3937 buildah \
4038 # Install dependencies for cryptography due to https://github.com/pyca/cryptography/issues/5771
4139 cargo \
42- curl \
4340 dnf-plugins-core \
4441 dotnet-sdk-${DOTNET_VERSION} \
42+ fuse-overlayfs \
4543 gcc \
4644 gcc-c++ \
4745 git \
48- java-${JAVA_VERSION}-openjdk \
4946 make \
5047 maven \
51- openssl \
5248 openssl-devel \
5349 podman-docker \
5450 python3 \
5551 python3-devel \
5652 python3-pip \
5753 rust \
58- unzip \
5954 wget \
6055 which \
6156 zip \
6257 && dnf clean all \
6358 && rm -rf /var/cache /var/log/dnf* /var/log/yum.*
6459
60+ # Podman
61+
62+ RUN groupadd --gid ${AGENT_GROUP_ID} ${AGENT_USER_NAME} \
63+ && useradd --gid ${AGENT_GROUP_ID} --uid ${AGENT_USER_ID} ${AGENT_USER_NAME} \
64+ && echo ${AGENT_USER_NAME}:10000:5000 > /etc/subuid \
65+ && echo ${AGENT_USER_NAME}:10000:5000 > /etc/subgid
66+
67+ VOLUME /var/lib/containers
68+ VOLUME /home/${AGENT_USER_NAME}/.local/share/containers
69+
70+ ADD https://raw.githubusercontent.com/containers/image_build/main/podman/containers.conf /etc/containers/containers.conf
71+ ADD https://raw.githubusercontent.com/containers/image_build/main/podman/podman-containers.conf /home/${AGENT_USER_NAME}/.config/containers/containers.conf
72+
73+ RUN chown ${AGENT_USER_ID}:${AGENT_GROUP_ID} -R /home/${AGENT_USER_NAME}
74+
75+ # chmod containers.conf and adjust storage.conf to enable Fuse storage.
76+ RUN chmod 644 /etc/containers/containers.conf \
77+ && sed -i -e 's|^#mount_program|mount_program|g' \
78+ -e '/additionalimage.*/a "/var/lib/shared",' \
79+ -e 's|^mountopt[[:space:]]*=.*$|mountopt = "nodev,fsync=0"|g' \
80+ /etc/containers/storage.conf \
81+ && mkdir -p /var/lib/shared/overlay-images \
82+ /var/lib/shared/overlay-layers \
83+ /var/lib/shared/vfs-images \
84+ /var/lib/shared/vfs-layers \
85+ && touch /var/lib/shared/overlay-images/images.lock \
86+ && touch /var/lib/shared/overlay-layers/layers.lock \
87+ && touch /var/lib/shared/vfs-images/images.lock \
88+ && touch /var/lib/shared/vfs-layers/layers.lock
89+
90+ ENV _CONTAINERS_USERNS_CONFIGURED=""
91+
6592# Create directories for the agent files
6693RUN mkdir ${AGENT_WORK_DIR} \
67- && chown -R ${AGENT_USER_NAME }:${AGENT_USER_NAME } ${AGENT_WORK_DIR} \
94+ && chown -R ${AGENT_USER_ID }:${AGENT_GROUP_ID } ${AGENT_WORK_DIR} \
6895 \
6996 # Download and unpack tarball
7097 && curl -L https://download.agent.dev.azure.com/agent/${AZURE_DEVOPS_AGENT_VERSION}/vsts-agent-${AGENT_PLATFORM:-linux-x64}-${AZURE_DEVOPS_AGENT_VERSION}.tar.gz -o /tmp/agent.tar.gz \
@@ -79,39 +106,7 @@ RUN sh ${AGENT_WORK_DIR}/bin/installdependencies.sh
79106COPY scripts/configure-and-run-agent.sh ${AGENT_WORK_DIR}/configure-and-run-agent.sh
80107
81108# Grant the correct permissions
82- RUN chown ${AGENT_USER_NAME}:${AGENT_USER_NAME} ${AGENT_WORK_DIR}/configure-and-run-agent.sh
83-
84- # Install the latest version of Ansible, along with the collections for major cloud providers
85- RUN pip3 install ansible --upgrade \
86- && pip3 install cryptography --upgrade \
87- && pip3 install -r https://raw.githubusercontent.com/ansible-collections/amazon.aws/${ANSIBLE_COLLECTION_AWS_VERSION}/requirements.txt \
88- # azure-iot-hub relies on the outdated uamqp library, which doesn't work with recent Python versions
89- && curl https://raw.githubusercontent.com/ansible-collections/azure/${ANSIBLE_COLLECTION_AZURE_VERSION}/requirements.txt | grep -ivE "azure-iot-hub|azure-mgmt-iothub" > azure-requirements.txt \
90- && pip3 install -r azure-requirements.txt \
91- && pip3 install -r https://raw.githubusercontent.com/ansible-collections/google.cloud/${ANSIBLE_COLLECTION_GCP_VERSION}/requirements.txt
92-
93- # Kubernetes & Helm
94- COPY conf/kubernetes.repo /etc/yum.repos.d/kubernetes.repo
95- RUN dnf install -y kubectl \
96- && dnf clean all \
97- && pip3 install kubernetes \
98- && curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/${HELM_VERSION}/scripts/get-helm-3 \
99- && chmod 700 get_helm.sh \
100- && ./get_helm.sh --version ${HELM_VERSION} \
101- && rm -f get_helm.sh \
102- && helm plugin install https://github.com/databus23/helm-diff
103-
104- # PostgreSQL
105- RUN dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/F-43-x86_64/pgdg-fedora-repo-latest.noarch.rpm \
106- && dnf install -y postgresql${POSTGRESQL_VERSION} \
107- && dnf clean all \
108- && pip3 install psycopg2-binary
109-
110- # Terraform
111- # Official documentation: https://developer.hashicorp.com/terraform/install
112- RUN dnf config-manager addrepo --from-repofile=https://rpm.releases.hashicorp.com/fedora/hashicorp.repo \
113- && dnf install -y terraform-${TERRAFORM_VERSION}* \
114- && dnf clean all
109+ RUN chown ${AGENT_USER_ID}:${AGENT_GROUP_ID} ${AGENT_WORK_DIR}/configure-and-run-agent.sh
115110
116111USER ${AGENT_USER_NAME}
117112
0 commit comments