-
-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathDockerfile-awsk8s
89 lines (80 loc) · 3.44 KB
/
Dockerfile-awsk8s
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
78
79
80
81
82
83
84
85
86
87
88
89
ARG VERSION
# --------------------------------------------------------------------------------------------------
# Builder Image
# --------------------------------------------------------------------------------------------------
FROM cytopia/ansible:${VERSION}-aws as builder
# Required tools for building Python packages
RUN set -eux \
&& apk add --no-cache \
# build tools
coreutils \
g++ \
gcc \
make \
musl-dev \
openssl-dev \
python3-dev \
# misc tools
curl
# Python packages (copied to final image)
RUN set -eux \
&& pip3 install --no-cache-dir --no-compile \
openshift \
&& find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \
&& find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf
# kubectl (copied to final image)
RUN set -eux \
&& if [ "$(uname -m)" = "aarch64" ]; then \
ARCH="arm64"; \
elif [ "$(uname -m)" = "x86_64" ]; then \
ARCH="amd64"; \
else \
fail; \
fi \
\
&& KUBECTL_VERSION="$(curl -sS --fail https://storage.googleapis.com/kubernetes-release/release/stable.txt)" \
&& curl -sS -L --fail -o /usr/bin/kubectl \
https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/${ARCH}/kubectl \
&& chmod +x /usr/bin/kubectl \
&& kubectl version --client --short=true 2>&1 | grep -E 'v[.0-9]+'
# openshift client (copied to final image)
RUN set -eux \
&& if [ "$(uname -m)" != "x86_64" ]; then \
echo -e '#!/bin/sh\necho "Not available for this platform"' > /usr/bin/oc \
&& chmod +x /usr/bin/oc \
&& exit 0; \
fi \
\
&& curl -sS -L --fail -o /tmp/openshift-client-linux.tar.gz \
https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz \
&& mkdir /tmp/openshift-client-linux/ \
&& tar -xzf /tmp/openshift-client-linux.tar.gz -C /tmp/openshift-client-linux/ \
&& mv /tmp/openshift-client-linux/oc /usr/bin/oc-dynamically-linked \
&& echo -e '#!/bin/sh\n/lib/ld-musl-$(uname -m).so.1 --library-path /lib /usr/bin/oc-dynamically-linked "$@"' > /usr/bin/oc \
&& chmod +x /usr/bin/oc \
&& oc version --client
# --------------------------------------------------------------------------------------------------
# Final Image
# --------------------------------------------------------------------------------------------------
FROM cytopia/ansible:${VERSION}-aws as production
ARG VERSION
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
#LABEL "org.opencontainers.image.created"=""
#LABEL "org.opencontainers.image.version"=""
#LABEL "org.opencontainers.image.revision"=""
LABEL "maintainer"="cytopia <cytopia@everythingcli.org>"
LABEL "org.opencontainers.image.authors"="cytopia <cytopia@everythingcli.org>"
LABEL "org.opencontainers.image.vendor"="cytopia"
LABEL "org.opencontainers.image.licenses"="MIT"
LABEL "org.opencontainers.image.url"="https://github.com/cytopia/docker-ansible"
LABEL "org.opencontainers.image.documentation"="https://github.com/cytopia/docker-ansible"
LABEL "org.opencontainers.image.source"="https://github.com/cytopia/docker-ansible"
LABEL "org.opencontainers.image.ref.name"="Ansible ${VERSION} awsk8s"
LABEL "org.opencontainers.image.title"="Ansible ${VERSION} awsk8s"
LABEL "org.opencontainers.image.description"="Ansible ${VERSION} awsk8s"
COPY --from=builder /usr/lib/python3.10/site-packages/ /usr/lib/python3.10/site-packages/
COPY --from=builder /usr/bin/kubectl /usr/bin/kubectl
COPY --from=builder /usr/bin/oc* /usr/bin/
WORKDIR /data
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/bin/bash"]