Skip to content

Commit

Permalink
numerous updates:
Browse files Browse the repository at this point in the history
* add builah, cgroup-tools, helm, procs, ripgrep, shadow, skopeo and, stress-ng.
* use native alpine packages for aws-cli, k9s, kubectl, krew, ctop, httpie and ipython
* add bash completions where available.
* call neofetch on startup.
* README cleanup

podman and buildah are broken.
  • Loading branch information
mindw committed Jul 1, 2023
1 parent e7877ee commit 7c0169c
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 99 deletions.
4 changes: 0 additions & 4 deletions .bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ alias where='which -a'

[ -f ~/.kubectl_aliases ] && source ~/.kubectl_aliases

source <(kubectl completion bash)
source <(stern --completion bash)
#source <(helm completion bash)

complete -F __start_kubectl k

export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
135 changes: 89 additions & 46 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
ARG ALPINE_VERSION=3.18
FROM python:3.11.3-alpine${ALPINE_VERSION} as builder

ARG AWS_CLI_VERSION=2.11.23
RUN apk add --no-cache git unzip groff build-base libffi-dev cmake
RUN git clone --single-branch --depth 1 -b ${AWS_CLI_VERSION} https://github.com/aws/aws-cli.git

WORKDIR aws-cli
RUN python -m venv venv
RUN . venv/bin/activate
RUN scripts/installers/make-exe
RUN unzip -q dist/awscli-exe.zip
RUN aws/install --bin-dir /aws-cli-bin
RUN /aws-cli-bin/aws --version

# reduce image size: remove autocomplete and examples
RUN rm -rf /usr/local/aws-cli/v2/current/dist/awscli/examples
RUN find /usr/local/aws-cli/v2/current/dist/awscli/botocore/data -name examples-1.json -delete

# build the final image
FROM alpine:${ALPINE_VERSION}
Expand All @@ -25,10 +8,21 @@ RUN set -ex; \
echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories; \
echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories; \
apk -U upgrade; \
apk add -u --no-cache !pyc\
btrfs-progs \
e2fsprogs \
e2fsprogs-extra \
shadow-uidmap \
xfsprogs \
xz \
pigz; \
apk add -u --no-cache !pyc\
7zip \
apache2-utils \
atop \
aws-cli \
aws-cli-bash-completion \
aws-cli-doc \
btop \
bash \
bash-completion \
Expand All @@ -38,39 +32,55 @@ RUN set -ex; \
bpftrace \
bpftrace-tools \
bridge-utils \
buildah \
busybox-extras \
ca-certificates \
cgroup-tools \
conntrack-tools \
coreutils \
curl \
ctop \
dhcping \
diffutils \
drill \
ethtool \
ethtool-bash-completion \
fatrace \
file \
findutils \
fio \
fping \
fuse-overlayfs \
git \
git-bash-completion \
grep \
helm \
helm-bash-completion \
hping3 \
htop \
httpie \
iftop \
inotify-tools \
ioping \
iperf \
iperf3 \
iproute2 \
iproute2-bash-completion \
ipset \
iptables \
ip6tables \
iptraf-ng \
iputils \
ipvsadm \
ipython \
jo \
jo-bash-completion \
jq \
k9s \
k9s-bash-completion \
kubectl \
kubectl-bash-completion \
kubectl-krew \
less \
liboping \
ltrace \
Expand All @@ -88,19 +98,34 @@ RUN set -ex; \
openssh \
openssl \
perf \
perf-bash-completion \
podman \
podman-bash-completion \
podman-docker \
podman-tui \
procps \
procs \
procs-bash-completion \
pstree \
py3-pip \
py3-pip-bash-completion \
py3-cryptography \
py3-yaml \
py3-ruamel.yaml \
py3-virtualenv \
python3 \
ripgrep \
ripgrep-bash-completion \
scapy \
shadow \
skopeo \
skopeo-bash-completion \
socat \
stern \
stern-bash-completion \
strace \
stress-ng \
stress-ng-bash-completion \
su-exec \
sudo \
swaks \
Expand All @@ -119,50 +144,27 @@ RUN set -ex; \
websocat \
wget \
wireguard-tools \
yq; \
wireguard-tools-bash-completion \
yq \
yq-bash-completion; \
rm -f /var/cache/apk/*

SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]

COPY --from=builder /usr/local/aws-cli/ /usr/local/aws-cli/
COPY --from=builder /aws-cli-bin/ /usr/local/bin/

# let's install httpie, httpx, ipython and jc
RUN pip3 install --upgrade --no-cache-dir httpie httpx[cli,brotli,http2,socks] ipython jc

# Installing ctop - top-like container monitor
ARG CTOP_VERSION=0.7.7
RUN \
wget -q https://github.com/bcicen/ctop/releases/download/v${CTOP_VERSION}/ctop-${CTOP_VERSION}-linux-amd64 -O /usr/local/bin/ctop; \
chmod +x /usr/local/bin/ctop
RUN pip3 install --upgrade --no-cache-dir httpx[cli,brotli,http2,socks] jc

# Installing calicoctl
ARG CALICOCTL_VERSION=v3.26.0
ARG CALICOCTL_VERSION=v3.26.1
RUN \
wget -q https://github.com/projectcalico/calico/releases/download/${CALICOCTL_VERSION}/calicoctl-linux-amd64 -O /usr/local/bin/calicoctl; \
chmod +x /usr/local/bin/calicoctl

# Installing kubectl
ARG KUBECTL_VERSION=v1.27.2
RUN \
wget -q https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl -O /usr/local/bin/kubectl; \
chmod +x /usr/local/bin/kubectl

# krew and plugins
# krew plugins
RUN \
curl --fail --silent -L --location https://github.com/kubernetes-sigs/krew/releases/latest/download/krew-linux_amd64.tar.gz | tar xz -C /tmp; \
/tmp/krew-linux_amd64 install krew; \
PATH="$HOME/.krew/bin:$PATH"; \
kubectl krew install cert-manager ctx explore get-all oidc-login node-shell ns relay resource-capacity sniff topology

# Installing K9s
ARG K9S_VERSION=v0.27.4
RUN \
curl --fail --silent -L https://github.com/derailed/k9s/releases/download/${K9S_VERSION}/k9s_Linux_amd64.tar.gz | \
tar zx k9s; \
chmod +x k9s; \
mv k9s /usr/local/bin

# Installing grpcurl
ARG GRPCURL_VERSION=1.8.7
RUN \
Expand All @@ -183,6 +185,47 @@ RUN \
RUN \
curl --fail --silent --location https://rawgit.com/ahmetb/kubectl-alias/master/.kubectl_aliases -o "$HOME/.kubectl_aliases"

# FIXME: figure out how to run podman in alpine container.
#RUN modprobe tun; \
# echo tun >>/etc/modules;

# setting up podman - https://github.com/containers/podman/blob/main/contrib/podmanimage/stable/Containerfile
RUN useradd podman; \
echo -e "podman:1:999\npodman:1001:64535" > /etc/subuid; \
echo -e "podman:1:999\npodman:1001:64535" > /etc/subgid;

ARG _REPO_URL="https://raw.githubusercontent.com/containers/podman/main/contrib/podmanimage/stable"
ADD $_REPO_URL/containers.conf /etc/containers/containers.conf
ADD $_REPO_URL/podman-containers.conf /home/podman/.config/containers/containers.conf

RUN mkdir -p /home/podman/.local/share/containers && \
chown podman:podman -R /home/podman && \
chmod 644 /etc/containers/containers.conf

# Copy & modify the defaults to provide reference if runtime changes needed.
# Changes here are required for running with fuse-overlay storage inside container.
RUN sed -e 's|^#mount_program|mount_program|g' \
-e '/additionalimage.*/a "/var/lib/shared",' \
-e 's|^mountopt[[:space:]]*=.*$|mountopt = "nodev,fsync=0"|g' \
/usr/share/containers/storage.conf \
> /etc/containers/storage.conf

# Note VOLUME options must always happen after the chown call above
# RUN commands can not modify existing volumes
#VOLUME /var/lib/containers
#VOLUME /home/podman/.local/share/containers

RUN mkdir -p /var/lib/shared/overlay-images \
/var/lib/shared/overlay-layers \
/var/lib/shared/vfs-images \
/var/lib/shared/vfs-layers && \
touch /var/lib/shared/overlay-images/images.lock && \
touch /var/lib/shared/overlay-layers/layers.lock && \
touch /var/lib/shared/vfs-images/images.lock && \
touch /var/lib/shared/vfs-layers/layers.lock

ENV _CONTAINERS_USERNS_CONFIGURED=""

# Settings
ADD motd /etc/motd
ADD .bashrc /root/.bashrc
Expand Down
Loading

0 comments on commit 7c0169c

Please sign in to comment.