forked from sjoshi10/docker-ansible-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.almalinux8
56 lines (46 loc) · 1.78 KB
/
Dockerfile.almalinux8
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
FROM almalinux:9.3-20231124
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 LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ONBUILD USER root
COPY requirements/requirements.txt ./requirements.txt
RUN dnf install -y epel-release \
&& dnf clean all \
&& dnf makecache \
&& dnf upgrade -y \
&& dnf install -y \
openssh \
sshpass \
git \
sudo \
python3-pip \
tar \
wget \
curl-minimal \
glibc-langpack-en \
tzdata \
# install gosu for a better su+exec command (remove sudo if this works)
&& curl -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 pip install --no-cache-dir --upgrade pip \
&& python3 -m pip install --no-cache-dir -r requirements.txt \
&& curl 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 \
&& dnf clean all \
&& rm -rf /var/cache/yum \
&& useradd -u 1000 ansible-1000 \
&& useradd -u 1001 ansible-1001 \
&& useradd -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" ]