forked from troykinsella/concourse-ansible-playbook-resource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
52 lines (41 loc) · 1.5 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
FROM alpine:3 as main
ARG ANSIBLE_VERSION
RUN set -eux; \
apk --update add bash openssh-client ruby git ruby-json python3 py3-pip openssl ca-certificates; \
apk --update add --virtual \
build-dependencies \
build-base \
python3-dev \
libffi-dev \
openssl-dev \
musl-dev \
cargo; \
pip3 install --upgrade pip cffi --break-system-packages; \
pip3 install "ansible==$ANSIBLE_VERSION" boto pywinrm --break-system-packages; \
apk del build-dependencies; \
rm -rf /var/cache/apk/*; \
# Remove PIP and Cargo cache
rm -rf /root/.cargo /root/.cache; \
# Remove Python cache files
find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf; \
find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf; \
# Add hosts for convenience
mkdir -p /etc/ansible; \
echo -e "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
COPY assets/ /opt/resource/
FROM main as testing
RUN set -eux; \
gem install rspec; \
wget -q -O - https://raw.githubusercontent.com/troykinsella/mockleton/master/install.sh | bash; \
cp /usr/local/bin/mockleton /usr/local/bin/ansible-galaxy; \
cp /usr/local/bin/mockleton /usr/local/bin/ansible-playbook; \
cp /usr/local/bin/mockleton /usr/bin/ssh-add;
COPY . /resource/
WORKDIR /resource
RUN rspec
FROM alpine:3 as print_latest_ansible_version
RUN apk --update add --no-cache py3-pip
COPY print_latest_ansible_version.sh /tools/
WORKDIR /tools
CMD ["./print_latest_ansible_version.sh"]
FROM main