diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 670b08d4952..332ee677509 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,7 +2,6 @@ "$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.schema.json", "name": "TrueCharts", "image": "tccr.io/tccr/devcontainer:v2.0.0@sha256:d8a12070a88e36cf1eb5b14fbeb1d5c866a1e5f8b52cc9e5989fb7f53c154b2b", - "initializeCommand": "docker pull tccr.io/tccr/devcontainer:v2.0.0", "postCreateCommand": { "setup": "bash ${containerWorkspaceFolder}/.devcontainer/postCreateCommand.sh" }, diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh index 4cc64c13890..0ec4bff56ab 100755 --- a/.devcontainer/postCreateCommand.sh +++ b/.devcontainer/postCreateCommand.sh @@ -12,9 +12,18 @@ fisher install nickeb96/puffer-fish fisher install PatrickF1/fzf.fish " -kubectl krew install pv-mounter +( + set -x; cd "$(mktemp -d)" && + OS="$(uname | tr '[:upper:]' '[:lower:]')" && + ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" && + KREW="krew-${OS}_${ARCH}" && + curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" && + tar zxvf "${KREW}.tar.gz" && + ./"${KREW}" install krew +) -# Create/update virtual environment -if ! grep -q "venv /workspaces/" .venv/pyvenv.cfg; then - rm -rf .venv -fi +export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH" + +kubectl krew install pv-mounter +kubectl krew install cnpg +kubectl krew install df-pv diff --git a/.github/renovate/main.json5 b/.github/renovate/main.json5 index e018627a696..5f58516b21d 100644 --- a/.github/renovate/main.json5 +++ b/.github/renovate/main.json5 @@ -36,7 +36,8 @@ "github>truecharts/public//.github/renovate/special/customClusterManagers.json5", "github>truecharts/public//.github/renovate/special/customRules.json5", "github>truecharts/public//.github/renovate/special/customVersioning.json5", - "github>truecharts/public//.github/renovate/special/customTalosClustertool.json5" + "github>truecharts/public//.github/renovate/special/customTalosClustertool.json5", + "github>truecharts/public//.github/renovate/special/devcontainer.json5" ], // Main Renovate configuration that lists package rules for various paths "packageRules": [ diff --git a/.github/renovate/special/devcontainer.json5 b/.github/renovate/special/devcontainer.json5 new file mode 100644 index 00000000000..d913c95c43d --- /dev/null +++ b/.github/renovate/special/devcontainer.json5 @@ -0,0 +1,18 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "customManagers": [ + { + "customType": "regex", + "managerFilePatterns": [ + "/Dockerfile$/" + ], + "matchStrings": [ + "ARG CLUSTERTOOL_VERSION=(?[0-9.]+)" + ], + "datasourceTemplate": "github-releases", + "packageNameTemplate": "truecharts/public", + "versioningTemplate": "semver", + "extractVersionTemplate": "^v(?.*)$" + } + ] +} diff --git a/clustertool/embed/generic/root/DOTREPLACEdevcontainer/devcontainer.json b/clustertool/embed/generic/root/DOTREPLACEdevcontainer/devcontainer.json index a619188a8ad..08f84dc0642 100644 --- a/clustertool/embed/generic/root/DOTREPLACEdevcontainer/devcontainer.json +++ b/clustertool/embed/generic/root/DOTREPLACEdevcontainer/devcontainer.json @@ -2,7 +2,6 @@ "$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.schema.json", "name": "ClusterTool Cluster", "image": "tccr.io/tccr/devcontainer:v2.0.0@sha256:d8a12070a88e36cf1eb5b14fbeb1d5c866a1e5f8b52cc9e5989fb7f53c154b2b", - "initializeCommand": "docker pull tccr.io/tccr/devcontainer:v2.0.0", "postCreateCommand": { "setup": "bash ${containerWorkspaceFolder}/.devcontainer/postCreateCommand.sh" }, diff --git a/clustertool/embed/generic/root/DOTREPLACEdevcontainer/postCreateCommand.sh b/clustertool/embed/generic/root/DOTREPLACEdevcontainer/postCreateCommand.sh index 4cc64c13890..0ec4bff56ab 100755 --- a/clustertool/embed/generic/root/DOTREPLACEdevcontainer/postCreateCommand.sh +++ b/clustertool/embed/generic/root/DOTREPLACEdevcontainer/postCreateCommand.sh @@ -12,9 +12,18 @@ fisher install nickeb96/puffer-fish fisher install PatrickF1/fzf.fish " -kubectl krew install pv-mounter +( + set -x; cd "$(mktemp -d)" && + OS="$(uname | tr '[:upper:]' '[:lower:]')" && + ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" && + KREW="krew-${OS}_${ARCH}" && + curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" && + tar zxvf "${KREW}.tar.gz" && + ./"${KREW}" install krew +) -# Create/update virtual environment -if ! grep -q "venv /workspaces/" .venv/pyvenv.cfg; then - rm -rf .venv -fi +export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH" + +kubectl krew install pv-mounter +kubectl krew install cnpg +kubectl krew install df-pv diff --git a/containers/apps/devcontainer/Dockerfile b/containers/apps/devcontainer/Dockerfile index 4eacd45d45f..eac0e9507ef 100644 --- a/containers/apps/devcontainer/Dockerfile +++ b/containers/apps/devcontainer/Dockerfile @@ -1,44 +1,89 @@ # hadolint ignore=DL3007 -FROM ghcr.io/onedr0p/cluster-template/devcontainer:latest@sha256:90bd47adcf1ac31e8d60e028e521db7a203a16186685546c298a5bb5e7ff642b +FROM mcr.microsoft.com/devcontainers/base:alpine -ARG VERSION +ARG CLUSTERTOOL_VERSION=2.0.0 ARG CONTAINER_NAME -ARG CONTAINER_VER # hadolint ignore=DL3008,DL3015,SC2086,SC2155 -RUN \ -apk update && \ - apk --no-cache update && \ +RUN apk update && \ apk --no-cache add \ - sshfs \ - libc6-compat \ - fuse && \ + age bash bind-tools ca-certificates curl direnv fish fzf \ + gettext git github-cli helm iputils jq k9s kubectl kustomize \ + python3 py3-pip moreutils openssh-client openssl starship yq \ + sshfs libc6-compat fuse && \ rm -rf /var/cache/apk/* /tmp/* /var/tmp/* +# Install CLI tools via jpillora scripts +RUN for app in \ + "budimanjojo/talhelper!!?as=talhelper&type=script" \ + "fluxcd/flux2!!?as=flux&type=script" \ + "helmfile/helmfile!!?as=helmfile&type=script" \ + "kubecolor/kubecolor!!?as=kubecolor&type=script" \ + "kubernetes-sigs/krew!!?as=krew&type=script" \ + "siderolabs/talos!!?as=talosctl&type=script"; \ + do \ + echo "=== Installing ${app} ==="; \ + curl -fsSL "https://i.jpillora.com/${app}" | bash; \ + done + +# Create the completions and conf.d directories explicitly +RUN mkdir -p /home/vscode/.config/fish/completions && \ + mkdir -p /home/vscode/.config/fish/conf.d + +# Add completions only if the command exists +RUN for tool in cilium flux helm helmfile k9s kubectl kustomize talhelper talosctl; do \ + if command -v "$tool" >/dev/null 2>&1; then \ + mkdir -p /home/vscode/.config/fish/completions && \ + $tool completion fish > "/home/vscode/.config/fish/completions/${tool}.fish" || true; \ + fi; \ + done && \ + gh completion --shell fish > /home/vscode/.config/fish/completions/gh.fish || true && \ + stern --completion fish > /home/vscode/.config/fish/completions/stern.fish || true && \ + yq shell-completion fish > /home/vscode/.config/fish/completions/yq.fish || true + +RUN mkdir -p /home/vscode/.config/fish/conf.d && \ + printf '%s\n' \ + "if status is-interactive" \ + " direnv hook fish | source" \ + " starship init fish | source" \ + "end" \ + > /home/vscode/.config/fish/conf.d/hooks.fish + +# Add aliases to fish config +RUN mkdir -p /home/vscode/.config/fish/conf.d && \ + printf '%s\n' \ + "alias kubectl kubecolor" \ + "alias k kubectl" \ + > /home/vscode/.config/fish/conf.d/aliases.fish + +# Custom fish prompt +RUN mkdir -p /home/vscode/.config/fish/conf.d && \ + echo "set fish_greeting" > /home/vscode/.config/fish/conf.d/fish_greeting.fish + +# Setup direnv whitelist +RUN mkdir -p /home/vscode/.config/direnv && \ + tee /home/vscode/.config/direnv/direnv.toml > /dev/null <