forked from sjoshi10/docker-ansible-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.alpine
57 lines (48 loc) · 2.07 KB
/
Dockerfile.alpine
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
FROM python:3.12.5-alpine
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 \
# Instructions for installing 1password cli: https://developer.1password.com/docs/cli/get-started/
echo https://downloads.1password.com/linux/alpinelinux/stable/ >> /etc/apk/repositories \
&& wget "https://downloads.1password.com/linux/keys/alpinelinux/support@1password.com-61ddfc31.rsa.pub" -P /etc/apk/keys \
&& apk update \
&& apk add --no-cache linux-headers \
build-base \
libffi-dev \
openssl-dev \
openssh \
sshpass \
git \
sudo \
tzdata \
cargo \
rsync \
1password-cli \
# 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 pip install --no-cache-dir --upgrade pip \
&& python3 -m pip install --no-cache-dir -r requirements.txt \
&& 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/local/bin/python3' > /etc/ansible/hosts \
&& rm -rf /var/cache/apk/* \
&& rm -rf /root/.cache \
&& adduser -u 1000 -D ansible-1000 \
&& adduser -u 1001 -D ansible-1001 \
&& adduser -u 10000 -D 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" ]