mirror of
https://github.com/outbackdingo/homelab-v.git
synced 2026-08-25 07:10:14 +00:00
feat(devcontainer): split into build and run configfiles
Signed-off-by: Vegard Hagen <[email protected]>
This commit is contained in:
@@ -1,2 +1,45 @@
|
||||
#FROM docker.io/ubuntu:24.04
|
||||
FROM mcr.microsoft.com/devcontainers/base:ubuntu22.04
|
||||
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,7 +1,8 @@
|
||||
# Devcontainer
|
||||
|
||||
A container with all the necessary tools and then some used in this homelab.
|
||||
Check available features at [https://containers.dev/features](https://containers.dev/features),
|
||||
The `devcontainer.json` file uses a pre-built image based on the configuration in the `devcontainer-build.json` file.
|
||||
|
||||
Check available Devcontainer features at [https://containers.dev/features](https://containers.dev/features),
|
||||
or edit the `Containerfile`.
|
||||
|
||||
**Disclaimer**: this is a fairly untested feature from the main author,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"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/go: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"
|
||||
}
|
||||
@@ -1,46 +1,12 @@
|
||||
{
|
||||
"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/aws-cli:1": {},
|
||||
"ghcr.io/devcontainers/features/azure-cli:1": {},
|
||||
"ghcr.io/devcontainers/features/github-cli:1": {},
|
||||
"ghcr.io/devcontainers/features/git:1": {},
|
||||
"ghcr.io/devcontainers/features/go:1": {},
|
||||
"ghcr.io/devcontainers/features/java:1": {},
|
||||
"ghcr.io/devcontainers/features/python:1": {},
|
||||
"ghcr.io/devcontainers/features/hugo:1": {
|
||||
"extended": "true"
|
||||
},
|
||||
"ghcr.io/devcontainers-extra/features/argo-cd:1": {},
|
||||
"ghcr.io/devcontainers-extra/features/helmfile:1": {},
|
||||
"ghcr.io/devcontainers-extra/features/kubectl-asdf:2": {},
|
||||
"ghcr.io/devcontainers-extra/features/kubectx-kubens:1": {},
|
||||
"ghcr.io/devcontainers-extra/features/talosctl:1": {},
|
||||
"ghcr.io/devcontainers-extra/features/yamllint:2": {},
|
||||
"ghcr.io/dhoeric/features/k9s:1": {},
|
||||
"ghcr.io/dhoeric/features/google-cloud-cli:1": {
|
||||
"installGkeGcloudAuthPlugin": true
|
||||
},
|
||||
"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": {},
|
||||
"ghcr.io/schlich/devcontainer-features/powerlevel10k:1": {},
|
||||
"ghcr.io/skriptfabrik/devcontainer-features/hcloud-cli:1": {},
|
||||
"ghcr.io/skriptfabrik/devcontainer-features/infisical-cli:1.1.1": {},
|
||||
},
|
||||
"name": "Homelab Devcontainer",
|
||||
"image": "ghcr.io/vehagn/homelab-devcontainer",
|
||||
"mounts": [
|
||||
{
|
||||
"source": "${env:HOME}${env:USERPROFILE}/.kube",
|
||||
"target": "/home/homelab/.kube",
|
||||
"type": "bind"
|
||||
}
|
||||
],
|
||||
"remoteUser": "homelab"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
name: Build devcontainer
|
||||
|
||||
on:
|
||||
workflow_dispatch: { }
|
||||
push:
|
||||
branches: [ main ]
|
||||
paths: [ ".devcontainer/**" ]
|
||||
@@ -12,7 +11,7 @@ jobs:
|
||||
build:
|
||||
name: Build devcontainer
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 240
|
||||
timeout-minutes: 120
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
@@ -37,6 +36,7 @@ jobs:
|
||||
- name: Pre-build dev container image
|
||||
uses: devcontainers/ci@8bf61b26e9c3a98f69cb6ce2f88d24ff59b785c6 #v0.3.1900000417
|
||||
with:
|
||||
configFile: ./.devcontainer/devcontainer-build.json
|
||||
platform: linux/amd64,linux/arm64
|
||||
imageName: ghcr.io/vehagn/homelab-devcontainer
|
||||
cacheFrom: ghcr.io/vehagn/homelab-devcontainer
|
||||
|
||||
@@ -39,7 +39,6 @@ jobs:
|
||||
- name: Tofu init
|
||||
uses: devcontainers/ci@8bf61b26e9c3a98f69cb6ce2f88d24ff59b785c6 #v0.3.1900000417
|
||||
with:
|
||||
imageName: ghcr.io/vehagn/homelab-devcontainer
|
||||
cacheFrom: ghcr.io/vehagn/homelab-devcontainer
|
||||
push: never
|
||||
runCmd: tofu -chdir=${{ env.TOFU_DIR }} init
|
||||
@@ -47,7 +46,6 @@ jobs:
|
||||
- name: Tofu validate
|
||||
uses: devcontainers/ci@8bf61b26e9c3a98f69cb6ce2f88d24ff59b785c6 #v0.3.1900000417
|
||||
with:
|
||||
imageName: ghcr.io/vehagn/homelab-devcontainer
|
||||
cacheFrom: ghcr.io/vehagn/homelab-devcontainer
|
||||
push: never
|
||||
runCmd: tofu -chdir=${{ env.TOFU_DIR }} validate
|
||||
@@ -55,7 +53,6 @@ jobs:
|
||||
- name: Tofu format
|
||||
uses: devcontainers/ci@8bf61b26e9c3a98f69cb6ce2f88d24ff59b785c6 #v0.3.1900000417
|
||||
with:
|
||||
imageName: ghcr.io/vehagn/homelab-devcontainer
|
||||
cacheFrom: ghcr.io/vehagn/homelab-devcontainer
|
||||
push: never
|
||||
runCmd: tofu -chdir=${{ env.TOFU_DIR }} fmt -recursive -diff -check
|
||||
|
||||
Reference in New Issue
Block a user