Initial set of brainfood-tools docker image.
Showing
3 changed files
with
105 additions
and
0 deletions
.dockerignore
0 → 100644
1 | .*.sw? |
Dockerfile
0 → 100644
1 | FROM scratch AS helm-remote | ||
2 | ARG HELM_VERSION=3.16.4 | ||
3 | ADD https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz /srv/helm-linux-amd64.tar.gz | ||
4 | |||
5 | FROM scratch AS helm-diff-remote | ||
6 | ARG HELM_DIFF_VERSION=3.5.0 | ||
7 | ADD https://github.com/databus23/helm-diff/releases/download/v${HELM_DIFF_VERSION}/helm-diff-linux-amd64.tgz /srv/helm-diff-linux-amd64.tgz | ||
8 | |||
9 | FROM scratch AS helm-git-remote | ||
10 | ARG HELM_GIT_VERSION=1.3.0 | ||
11 | ADD https://github.com/aslafy-z/helm-git/archive/refs/tags/v${HELM_GIT_VERSION}.tar.gz /srv/helm-git.tar.gz | ||
12 | |||
13 | FROM scratch AS helmfile-remote | ||
14 | ARG HELMFILE_VERSION=0.149.0 | ||
15 | ADD https://github.com/helmfile/helmfile/releases/download/v${HELMFILE_VERSION}/helmfile_${HELMFILE_VERSION}_linux_amd64.tar.gz /srv/helmfile_linux_amd64.tar.gz | ||
16 | |||
17 | FROM scratch AS kubectl-remote | ||
18 | ARG KUBECTL_VERSION=1.24.1 | ||
19 | ADD https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl /srv/kubectl | ||
20 | |||
21 | FROM scratch AS kustomize-remote | ||
22 | ARG KUSTOMIZE_VERSION=3.8.0 | ||
23 | #ARG KUSTOMIZE_VERSION=5.5.0 | ||
24 | ADD https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_amd64.tar.gz /srv/kustomize_linux_amd64.tar.gz | ||
25 | |||
26 | FROM debian:bookworm-20241223-slim AS host-base-tools | ||
27 | |||
28 | RUN true && \ | ||
29 | apt-get update && \ | ||
30 | apt-get install -y git && \ | ||
31 | adduser tool && \ | ||
32 | getent passwd && \ | ||
33 | true | ||
34 | |||
35 | FROM host-base-tools as host-build-tools | ||
36 | COPY --from=helm-remote /srv/helm-linux-amd64.tar.gz /srv/helm-linux-amd64.tar.gz | ||
37 | COPY --from=helm-diff-remote /srv/helm-diff-linux-amd64.tgz /srv/helm-diff-linux-amd64.tgz | ||
38 | COPY --from=helm-git-remote /srv/helm-git.tar.gz /srv/helm-git.tar.gz | ||
39 | COPY --from=helmfile-remote /srv/helmfile_linux_amd64.tar.gz /srv/helmfile_linux_amd64.tar.gz | ||
40 | COPY --from=kubectl-remote /srv/kubectl /usr/local/bin/kubectl | ||
41 | COPY --from=kustomize-remote /srv/kustomize_linux_amd64.tar.gz /srv/kustomize_linux_amd64.tar.gz | ||
42 | |||
43 | RUN true && set -x && \ | ||
44 | chown tool:tool /srv/* && \ | ||
45 | chmod +x /usr/local/bin/kubectl && \ | ||
46 | cd /tmp && \ | ||
47 | mkdir install && cd install && \ | ||
48 | tar -zxvf /srv/helm-linux-amd64.tar.gz && \ | ||
49 | mv linux-amd64/helm /usr/local/bin/helm && \ | ||
50 | cd .. && rm -rf install && \ | ||
51 | mkdir install && cd install && \ | ||
52 | tar -zxvf /srv/helmfile_linux_amd64.tar.gz && \ | ||
53 | mv helmfile /usr/local/bin/helmfile && \ | ||
54 | cd .. && rm -rf install && \ | ||
55 | mkdir install && cd install && \ | ||
56 | tar -zxvf /srv/kustomize_linux_amd64.tar.gz && \ | ||
57 | mv kustomize /usr/local/bin/kustomize && \ | ||
58 | cd .. && rm -rf install && \ | ||
59 | true | ||
60 | |||
61 | USER tool:tool | ||
62 | RUN true && set -x && \ | ||
63 | cd /home/tool && \ | ||
64 | helm env > /tmp/.helm-env && . /tmp/.helm-env && rm /tmp/.helm-env && \ | ||
65 | mkdir -p $HELM_PLUGINS && \ | ||
66 | tar -C $HELM_PLUGINS -xf /srv/helm-diff-linux-amd64.tgz && \ | ||
67 | tar -C $HELM_PLUGINS -xf /srv/helm-git.tar.gz && \ | ||
68 | helm version && helm plugin list && \ | ||
69 | helmfile version && \ | ||
70 | mkdir -p .config/kustomize/plugins && \ | ||
71 | mkdir .ssh && chmod 700 .ssh && \ | ||
72 | true | ||
73 | |||
74 | FROM host-base-tools as final-output | ||
75 | COPY --from=host-build-tools /home/tool/ /home/tool/ | ||
76 | COPY --from=host-build-tools /usr/local/bin/ /usr/local/bin/ | ||
77 | COPY --from=host-build-tools /usr/local/sbin/ /usr/local/sbin/ | ||
78 | COPY entrypoint.sh /usr/local/sbin/entrypoint.sh | ||
79 | ENTRYPOINT ["entrypoint.sh"] |
entrypoint.sh
0 → 100755
1 | #!/bin/bash | ||
2 | |||
3 | set -ex | ||
4 | |||
5 | configure_ssh_known_hosts() { | ||
6 | if [[ -z $SSH_KNOWN_HOSTS ]]; then return; fi | ||
7 | for host in $SSH_KNOWN_HOSTS; do | ||
8 | ssh-keyscan $host 2>/dev/null | ||
9 | done > "/home/tool/.ssh/known_hosts" | ||
10 | chown tool:tool "/home/tool/.ssh/known_hosts" | ||
11 | } | ||
12 | |||
13 | configure_ssh_config() { | ||
14 | { | ||
15 | echo "Host *" | ||
16 | echo " PubkeyAcceptedAlgorithms +ssh-rsa" | ||
17 | } > "/home/tool/.ssh/config" | ||
18 | chown tool:tool "/home/tool/.ssh/config" | ||
19 | } | ||
20 | |||
21 | configure_ssh_known_hosts | ||
22 | configure_ssh_config | ||
23 | |||
24 | [[ $# -eq 0 ]] && set -- "bash" | ||
25 | exec "$@" |
-
Please register or sign in to post a comment