|
| 1 | +# OpenTofu Image to provide tofu binary for COPY command below |
| 2 | +FROM ghcr.io/opentofu/opentofu:minimal AS tofu |
| 3 | + |
| 4 | +# Baseimage |
| 5 | +FROM alpine:3.22 |
| 6 | +# 14MB |
| 7 | + |
| 8 | +############## Set variables for easier modifications while building ########### |
| 9 | + |
| 10 | +# ANSIBLE_INSTALLATION |
| 11 | +# set to "ansible" for full installation (~730MB) |
| 12 | +# set to "ansible-core" for minimal installation (~90MB) |
| 13 | +ARG ANSIBLE_PYTHON_MODULE="ansible-core" |
| 14 | + |
| 15 | +# Version of kubectl to install |
| 16 | +# set to version from GitHub releases page here: |
| 17 | +# https://github.com/kubernetes/kubernetes/releases |
| 18 | +ARG KUBECTL_VERSION="v1.34.1" |
| 19 | + |
| 20 | +# Version of k9s to install |
| 21 | +# set to version from GitHub releases page here: |
| 22 | +# https://github.com/derailed/k9s/releases |
| 23 | +ARG K9S_VERSION="v0.50.16" |
| 24 | + |
| 25 | +# Version of helm to install |
| 26 | +# set to version from GitHub releases page here: |
| 27 | +# https://github.com/helm/helm/releases |
| 28 | +ARG HELM_VERSION="v3.19.0" |
| 29 | + |
| 30 | +# Version of gardenlogin to install |
| 31 | +# set to version from GitHub releases page here: |
| 32 | +# https://github.com/gardener/gardenlogin/releases |
| 33 | +ARG GARDENLOGIN_VERSION="v0.7.1" |
| 34 | + |
| 35 | +# Version of kubelogin to install |
| 36 | +# set to version from GitHub releases page here: |
| 37 | +# https://github.com/int128/kubelogin/releases |
| 38 | +ARG KUBELOGIN_VERSION="v1.34.2" |
| 39 | + |
| 40 | +################################################################################ |
| 41 | + |
| 42 | +# Set default directory to work and run all commands from |
| 43 | +WORKDIR /workspace |
| 44 | + |
| 45 | +# Install OpenTofu following the documentation here: |
| 46 | +# https://opentofu.org/docs/intro/install/docker/ |
| 47 | +# + ~110MB |
| 48 | +COPY --from=tofu /usr/local/bin/tofu /usr/local/bin/tofu |
| 49 | + |
| 50 | +# Install curl, tar, build utilities (like gcc and headers) and pip |
| 51 | +# to virtual .build-deps package to remove them later (keeping the image as |
| 52 | +# small as possible) |
| 53 | +# |
| 54 | +# Install python3-dev as direct dependency for Ansible and the openstackclient |
| 55 | +# (can not be removed later, since those depend on it) |
| 56 | +# + ~140MB |
| 57 | +# |
| 58 | +## Install Ansible (full) to virtual environment following the documentation here: |
| 59 | +## https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#pip-install |
| 60 | +## + ~730MB |
| 61 | +## |
| 62 | +## OR |
| 63 | +## |
| 64 | +## Install Ansible (ansible-core only) to virtual environment following the |
| 65 | +## documentation here: |
| 66 | +## https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#pip-install |
| 67 | +## + ~90MB |
| 68 | +# |
| 69 | +# Install openstackclient to virtual environment following the documentation |
| 70 | +# here: |
| 71 | +# https://docs.openstack.org/newton/user-guide/common/cli-install-openstack-command-line-clients.html |
| 72 | +# + ~200MB |
| 73 | +# |
| 74 | +# Install kubectl following the documentation here: |
| 75 | +# https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/ |
| 76 | +# + ~80MB |
| 77 | +# |
| 78 | +# Install k9s with apk directly downloaded from the current GitHub releases |
| 79 | +# https://k9scli.io/topics/install/ |
| 80 | +# + ~180MB |
| 81 | +# |
| 82 | +# Install helm from GitHub releases following the documentation here: |
| 83 | +# https://helm.sh/docs/intro/install/#from-the-binary-releases |
| 84 | +# + ~80MB |
| 85 | +# |
| 86 | +# Install gardenlogin from GitHub releases following the documentation here: |
| 87 | +# https://github.com/gardener/gardenlogin?tab=readme-ov-file#install-from-github-release |
| 88 | +# + ~90MB |
| 89 | +# |
| 90 | +# Install kubelogin from GitHub releases following the documentation here: |
| 91 | +# https://github.com/int128/kubelogin/tree/master?tab=readme-ov-file#getting-started |
| 92 | +# + ~20MB |
| 93 | +# |
| 94 | +# Cleanup virtual build-deps package |
| 95 | + |
| 96 | +## Total image ~1.7GB with full ansible |
| 97 | +## Total image ~1.0GB with ansible-core |
| 98 | +RUN apk update --no-cache &&\ |
| 99 | + apk add --no-cache --virtual .build-deps \ |
| 100 | + curl gcc py3-pip tar musl-dev linux-headers &&\ |
| 101 | + apk add --no-cache python3-dev &&\ |
| 102 | + python3 -m venv ansible &&\ |
| 103 | + source ansible/bin/activate &&\ |
| 104 | + pip install "${ANSIBLE_PYTHON_MODULE}" &&\ |
| 105 | + deactivate &&\ |
| 106 | + python3 -m venv openstackclient &&\ |
| 107 | + source openstackclient/bin/activate &&\ |
| 108 | + pip install python-openstackclient &&\ |
| 109 | + deactivate &&\ |
| 110 | + curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" &&\ |
| 111 | + install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl &&\ |
| 112 | + rm kubectl &&\ |
| 113 | + curl -LO "https://github.com/derailed/k9s/releases/download/${K9S_VERSION}/k9s_linux_amd64.apk" &&\ |
| 114 | + apk add --allow-untrusted k9s_linux_amd64.apk &&\ |
| 115 | + rm k9s_linux_amd64.apk &&\ |
| 116 | + curl -LO "https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz" &&\ |
| 117 | + tar -zxf "helm-${HELM_VERSION}-linux-amd64.tar.gz" &&\ |
| 118 | + install -o root -g root -m 0755 linux-amd64/helm /usr/local/bin/helm &&\ |
| 119 | + rm -r linux-amd64 &&\ |
| 120 | + rm "helm-${HELM_VERSION}-linux-amd64.tar.gz" &&\ |
| 121 | + curl -LO "https://github.com/gardener/gardenlogin/releases/download/${GARDENLOGIN_VERSION}/gardenlogin_linux_amd64" &&\ |
| 122 | + install -o root -g root -m 0755 gardenlogin_linux_amd64 /usr/local/bin/gardenlogin &&\ |
| 123 | + ln -s /usr/local/bin/gardenlogin /usr/local/bin/kubectl-gardenlogin &&\ |
| 124 | + rm gardenlogin_linux_amd64 &&\ |
| 125 | + curl -LO "https://github.com/int128/kubelogin/releases/download/${KUBELOGIN_VERSION}/kubelogin_linux_amd64.zip" &&\ |
| 126 | + unzip kubelogin_linux_amd64.zip &&\ |
| 127 | + install -o root -g root -m 0755 kubelogin /usr/local/bin/kubelogin &&\ |
| 128 | + ln -s /usr/local/bin/kubelogin /usr/local/bin/kubectl-oidc_login &&\ |
| 129 | + rm kubelogin README.md LICENSE &&\ |
| 130 | + rm kubelogin_linux_amd64.zip &&\ |
| 131 | + apk del .build-deps |
0 commit comments