-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile.ubuntu
58 lines (49 loc) · 1.97 KB
/
Dockerfile.ubuntu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
FROM ubuntu:24.04
LABEL org.opencontainers.image.title="haxorof/ansible-core" \
org.opencontainers.image.description="Ansible Core + additions" \
org.opencontainers.image.licenses="MIT"
ARG docker_version
ARG gosu_version
ENV DEBIAN_FRONTEND=noninteractive
ENV DEFAULT_LOCAL_TMP=/var/tmp/.ansible/tmp
ENV VIRTUAL_ENV=/.env
ENV PATH=$VIRTUAL_ENV/bin:$PATH
ONBUILD USER root
COPY requirements/requirements.txt ./requirements.txt
RUN apt-get clean \
&& apt-get -y update \
&& apt-get -y install apt-utils \
&& apt-get -y upgrade \
&& apt-get -y install \
sshpass \
git \
sudo \
python3-pip \
python3-venv \
wget \
curl \
tzdata \
cargo \
# install gosu for a better su+exec command (remove sudo if this works)
&& wget -O /usr/bin/gosu "https://github.com/tianon/gosu/releases/download/$gosu_version/gosu-amd64" \
&& chmod +x /usr/bin/gosu \
&& gosu nobody true \
&& python3 -m venv ${VIRTUAL_ENV} \
&& python3 -m pip install --no-cache-dir --break-system-packages --upgrade pip \
&& python3 -m pip install --no-cache-dir --break-system-packages -r requirements.txt \
&& chmod -R +wr ${VIRTUAL_ENV} \
&& wget -O - https://download.docker.com/linux/static/stable/x86_64/docker-${docker_version}.tgz | tar -xz -C /usr/lib \
&& ln -s /usr/lib/docker/docker /usr/bin/docker \
&& mkdir -p /etc/ansible/roles \
&& echo 'localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python3' > /etc/ansible/hosts \
&& apt-get clean \
&& userdel -r ubuntu \
&& useradd -m -u 1000 ansible-1000 \
&& useradd -m -u 1001 ansible-1001 \
&& useradd -m -u 10000 ansible-10000 \
&& echo 'ansible-1000 ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/ansible \
&& echo 'ansible-1001 ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/ansible \
&& echo 'ansible-10000 ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/ansible
WORKDIR /mnt
USER ansible-10000
CMD [ "ansible-playbook", "playbook.yml" ]