mirror of
https://github.com/outbackdingo/homelab-v.git
synced 2026-08-25 07:10:14 +00:00
46 lines
1.7 KiB
Docker
46 lines
1.7 KiB
Docker
FROM docker.io/ubuntu:24.04
|
|
ARG TARGETARCH
|
|
|
|
RUN rm -rf /home/ubuntu
|
|
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
apt-transport-https \
|
|
ca-certificates \
|
|
curl \
|
|
wget \
|
|
gnupg \
|
|
git
|
|
|
|
# Fetch kubectl
|
|
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${TARGETARCH}/kubectl" && \
|
|
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${TARGETARCH}/kubectl.sha256" && \
|
|
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check && \
|
|
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && \
|
|
rm kubectl kubectl.sha256
|
|
|
|
# Install kubecolor for some colour https://kubecolor.github.io/
|
|
RUN wget -O /tmp/kubecolor.deb https://kubecolor.github.io/packages/deb/pool/main/k/kubecolor/kubecolor_$(wget -q -O- https://kubecolor.github.io/packages/deb/version)_$(dpkg --print-architecture).deb && \
|
|
dpkg -i /tmp/kubecolor.deb && \
|
|
apt update && \
|
|
rm /tmp/kubecolor.deb
|
|
|
|
RUN adduser homelab
|
|
USER homelab
|
|
|
|
# Install krew, a plugin manager for kubectl https://krew.sigs.k8s.io/
|
|
RUN (set -x; cd "$(mktemp -d)" && \
|
|
KREW="krew-linux_${TARGETARCH}" && \
|
|
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" && \
|
|
tar zxvf "${KREW}.tar.gz" && \
|
|
./"${KREW}" install krew ) && \
|
|
echo "export PATH=\"${KREW_ROOT:-$HOME/.krew}/bin:$PATH\"" >> ${HOME}/.bashrc
|
|
|
|
RUN PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH" kubectl krew install ctx ns oidc-login
|
|
|
|
RUN echo "alias k='kubectl'" >> ${HOME}/.bash_aliases && \
|
|
echo "alias kubectl='kubecolor'" >> ${HOME}/.bash_aliases && \
|
|
echo "alias tf='tofu'" >> ${HOME}/.bash_aliases
|
|
|
|
USER root
|