-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.alpine
57 lines (48 loc) · 2.01 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:alpine3.15
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 en_US.UTF-8
ENV LC_ALL en_US.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 apk --update-cache upgrade \
&& apk add --no-cache linux-headers \
build-base \
libffi-dev \
openssl-dev \
openssh \
sshpass \
git \
sudo \
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 --upgrade pip \
&& python3 -m pip install --no-cache-dir --upgrade wheel \
&& python3 -m pip install --no-cache-dir -r requirements.txt \
&& python3 -m pip install --no-cache-dir -r requirements-extras.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" ]