-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
77 lines (69 loc) · 2.19 KB
/
Dockerfile
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
FROM alpine:3.16.2 as builder
RUN apk --update --no-cache add \
gcc \
libffi-dev \
make \
musl-dev \
python3 \
bc \
ca-certificates \
git \
openssh-client \
rsync \
curl \
&& apk --update --no-cache add --virtual \
.build-deps \
sshpass \
python3-dev \
libffi-dev \
openssl-dev \
build-base \
py3-pip \
py3-wheel \
rust \
cargo \
libxml2 \
libxslt-dev
COPY requirements.txt /requirements.txt
RUN set -eux \
&& pip3 install --no-cache-dir --upgrade -r /requirements.txt \
&& find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \
&& find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf
FROM alpine:3.16.2 as production
COPY --from=builder /usr/lib/python3.10/site-packages/ /usr/lib/python3.10/site-packages/
COPY --from=builder /usr/bin/ansible /usr/bin/ansible
COPY --from=builder /usr/bin/ansible-connection /usr/bin/ansible-connection
COPY --from=builder /usr/bin/flake8 /usr/bin/flake8
COPY --from=builder /usr/bin/molecule /usr/bin/molecule
COPY --from=builder /usr/bin/pytest /usr/bin/pytest
COPY --from=builder /usr/bin/yamllint /usr/bin/yamllint
COPY --from=builder /usr/bin/ansible-lint /usr/bin/ansible-lint
RUN set -eux \
&& apk add --no-cache \
bash \
git \
gnupg \
jq \
openssh-client \
openssl \
python3 \
sshpass \
rsync \
libxml2 \
libxslt-dev \
&& ln -sf /usr/bin/python3 /usr/bin/python \
&& ln -sf ansible /usr/bin/ansible-config \
&& ln -sf ansible /usr/bin/ansible-console \
&& ln -sf ansible /usr/bin/ansible-doc \
&& ln -sf ansible /usr/bin/ansible-galaxy \
&& ln -sf ansible /usr/bin/ansible-inventory \
&& ln -sf ansible /usr/bin/ansible-playbook \
&& ln -sf ansible /usr/bin/ansible-pull \
&& ln -sf ansible /usr/bin/ansible-test \
&& ln -sf ansible /usr/bin/ansible-vault \
&& find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \
&& find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf
RUN ansible-galaxy collection install community.docker community.general \
&& mkdir -p /usr/share/ansible \
&& ln -s /root/.ansible/collections/ /usr/share/ansible/collections
CMD ["sh", "-c", "cd ${WORKING_DIRECTORY}; PY_COLORS=1 ANSIBLE_FORCE_COLOR=1 molecule ${COMMAND:-test} --scenario-name ${SCENARIO:-default}"]