-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.almalinux
63 lines (53 loc) · 2.09 KB
/
Dockerfile.almalinux
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
59
60
61
62
63
FROM almalinux/9-base:9.5-20241118
LABEL org.opencontainers.image.title="haxorof/ansible" \
org.opencontainers.image.description="Ansible + additions" \
org.opencontainers.image.licenses="MIT"
ARG docker_version
ARG gosu_version
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV VIRTUAL_ENV=/.env
ENV PATH=$VIRTUAL_ENV/bin:$PATH
ONBUILD USER root
COPY requirements/requirements.txt ./requirements.txt
COPY requirements/extras/requirements.txt ./requirements-extras.txt
RUN dnf install -y epel-release \
&& dnf clean all \
&& dnf makecache \
&& dnf upgrade -y \
&& dnf install -y \
openssh \
sshpass \
git \
sudo \
python3.11 \
python3.11-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.11 -m venv ${VIRTUAL_ENV} \
&& python3.11 -m pip install --no-cache-dir --upgrade pip \
&& python3.11 -m pip install --no-cache-dir --upgrade wheel \
&& python3.11 -m pip install --no-cache-dir -r requirements.txt \
&& python3.11 -m pip install --no-cache-dir -r requirements-extras.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" ]