mirror of
https://github.com/outbackdingo/homelab-v.git
synced 2026-08-25 14:53:19 +00:00
feat(devcontainer): do more in Containerfile for thinner image
Signed-off-by: Vegard Hagen <[email protected]>
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
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
|
||||
@@ -1,9 +1,10 @@
|
||||
# Devcontainer
|
||||
|
||||
The `devcontainer.json` file uses a pre-built image based on the configuration in the `devcontainer-build.json` file.
|
||||
The `devcontainer.json` file uses a pre-built image based on the configuration in the `./.github/.devcontainer`
|
||||
directory.
|
||||
|
||||
Check available Devcontainer features at [https://containers.dev/features](https://containers.dev/features),
|
||||
or edit the `Containerfile`.
|
||||
or edit the `Containerfile` there.
|
||||
|
||||
**Disclaimer**: this is a fairly untested feature from the main author,
|
||||
feedback is welcome.
|
||||
@@ -19,7 +20,7 @@ Alternatively, you can start the devcontainer manually by running
|
||||
|
||||
```shell
|
||||
docker run -it --rm \
|
||||
--user $(id -u):$(id -g) \
|
||||
--user dev \
|
||||
--name homelab-devcontainer \
|
||||
--mount target=/tmp,type=tmpfs \
|
||||
--mount type=bind,src=.,dst=/workspace \
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"name": "Stonegarden Homelab Devcontainer",
|
||||
"build": {
|
||||
"dockerfile": "Containerfile"
|
||||
},
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/common-utils:2": {
|
||||
"installZsh": true,
|
||||
"configureZshAsDefaultShell": true,
|
||||
"installOhMyZsh": true,
|
||||
"installOhMyZshConfig": true,
|
||||
"upgradePackages": true,
|
||||
"username": "homelab"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/github-cli:1": {},
|
||||
"ghcr.io/devcontainers/features/java:1": {},
|
||||
"ghcr.io/devcontainers-extra/features/argo-cd:1": {},
|
||||
"ghcr.io/devcontainers-extra/features/talosctl:1": {},
|
||||
"ghcr.io/devcontainers-extra/features/yamllint:2": {},
|
||||
"ghcr.io/dhoeric/features/k9s:1": {},
|
||||
"ghcr.io/eitsupi/devcontainer-features/jq-likes": {
|
||||
"jqVersion": "latest",
|
||||
"yqVersion": "latest"
|
||||
},
|
||||
"ghcr.io/robbert229/devcontainer-features/postgresql-client:1": {},
|
||||
"ghcr.io/robbert229/devcontainer-features/opentofu:1": {}
|
||||
},
|
||||
"remoteUser": "homelab"
|
||||
}
|
||||
@@ -8,5 +8,5 @@
|
||||
"type": "bind"
|
||||
}
|
||||
],
|
||||
"remoteUser": "homelab"
|
||||
"remoteUser": "dev"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user