
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
ENV JENKINS_HOME=/home/jenkins
ENV HOME=/home/jenkins
ENV PIPENV_VENV_IN_PROJECT=true
ENV TZ=Europe/London
SHELL ["/bin/bash", "-c"]

RUN groupadd -g 386 jenkins && useradd -m -u 386 -g 386 -s /bin/bash jenkins
### Note: use pip to install pipenv (not apt) to avoid pypa/pipenv#2196 (when using PIPENV_VENV_IN_PROJECT)
RUN apt-get update                 && apt-get install -y git iproute2 python3-boto python3-boto3 python3-dev python3-distutils python3-docker python3-dnspython python3-google-auth python3-googleapi python3-jinja2 python3-jmespath python3-libcloud python3-libvirt python3-lxml python3-netaddr python3-paramiko python3-passlib python3-pip python3-pyvmomi python3-ruamel.yaml python3-setuptools python3-wheel python3-xmltodict                 && pip3 install pycdlib pipenv ansible==8.2.0
RUN if [ $(echo -e "$(pip3 show ansible | grep ^Version | sed -r 's/^Version: (.*)/\1/')\n6.4.0"|sort|head -1) != "6.4.0" ]; then ansible-galaxy collection install community.libvirt:==1.2.0 -p $(pip3 show ansible | grep ^Location | sed 's/Location: \(.*\)/\1/') --force; fi                 && if [ $(echo -e "$(pip3 show ansible | grep ^Version | sed -r 's/^Version: (.*)/\1/')\n6.1.0"|sort|head -1) != "6.1.0" ]; then ansible-galaxy collection install azure.azcollection:==1.13.0 -p $(pip3 show ansible | grep ^Location | sed 's/Location: \(.*\)/\1/') --force; fi                 && pip3 install -r $(pip3 show ansible | grep ^Location | sed -r 's/^Location: (.*)/\1/')/ansible_collections/azure/azcollection/requirements-azure.txt
