From d9a1d299eac075d70bf11b1f8b4962921331fa4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Fernandes?= Date: Fri, 17 Jul 2026 22:44:55 +0000 Subject: [PATCH] add container-builder dev container --- .../devcontainer.json | 48 +++++++++ .gitea/workflows/image-deploy.yaml | 15 +++ README.md | 12 ++- container-builder/assets/.zshrc | 8 ++ container-builder/templates/devcontainer.json | 34 +++++++ container-builder/ubuntu-fatboy.Dockerfile | 99 +++++++++++++++++++ 6 files changed, 214 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/container-builder-ubuntu-fatboy/devcontainer.json create mode 100644 container-builder/assets/.zshrc create mode 100644 container-builder/templates/devcontainer.json create mode 100644 container-builder/ubuntu-fatboy.Dockerfile diff --git a/.devcontainer/container-builder-ubuntu-fatboy/devcontainer.json b/.devcontainer/container-builder-ubuntu-fatboy/devcontainer.json new file mode 100644 index 0000000..0c9910e --- /dev/null +++ b/.devcontainer/container-builder-ubuntu-fatboy/devcontainer.json @@ -0,0 +1,48 @@ +// ⚠️ Temporary / Testing Only ⚠️ +// ----------------------------------------------------------------------------- +// This devcontainer.json is provided solely for local testing and experimentation. +// It is NOT the canonical configuration for DevOps projects. +// +// ✅ The single source of truth lives in: +// - README.md (usage instructions) +// - /devops/templates/devcontainer.json (baseline template) +// +// Always consult those files before making changes. This file may diverge, +// and should never be treated as the authoritative definition. +// ----------------------------------------------------------------------------- +{ + "build": { + "dockerfile": "../../container-builder/ubuntu-fatboy.Dockerfile", + "context": "../../container-builder" + }, + "remoteUser": "code", + "name": "container-builder-ubuntu-fatboy", + "runArgs": [ + "--hostname=container-builder-ubuntu-fatboy" + ], + "mounts": [ + "source=${localEnv:HOME}/.gitconfig,target=/home/code/.gitconfig,type=bind", + "source=${localEnv:HOME}/.ssh,target=/home/code/.ssh,type=bind" + ], + "remoteEnv": { + "DOCKER_HOST": "ssh://mf@lazarus" + }, + "customizations": { + "vscode": { + "extensions": [ + "stateful.runme", + "yzhang.markdown-all-in-one", + "davidanson.vscode-markdownlint", + "eamodio.gitlens", + "m4ns0ur.base64", + "rogalmic.bash-debug", + "streetsidesoftware.code-spell-checker", + "ms-azuretools.vscode-containers", + "eamodio.gitlens", + "shd101wyy.markdown-preview-enhanced", + "bierner.markdown-mermaid", + "bierner.markdown-preview-github-styles" + ] + } + } +} diff --git a/.gitea/workflows/image-deploy.yaml b/.gitea/workflows/image-deploy.yaml index 27d13ca..d414e72 100644 --- a/.gitea/workflows/image-deploy.yaml +++ b/.gitea/workflows/image-deploy.yaml @@ -33,3 +33,18 @@ jobs: buildkit_addr: ${{ vars.BUILDKIT_ADDRESS }} dockerfile: ${{gitea.workspace}}/devops context: ${{gitea.workspace}}/devops + + - name: Build and push Image + uses: ./.gitea/limbo_actions/buildkit-build-push + with: + tags: > + oci.limbosolutions.com/public/devcontainers/container-builder:latest + oci.limbosolutions.com/public/devcontainers/container-builder:ubuntu-fatboy-latest + oci.limbosolutions.com/public/devcontainers/container-builder:fatboy-latest + registry_addr: ${{ vars.OCI_LIMBO_REGISTRY_ADDRESS }} + registry_username: ${{ secrets.OCI_LIMBO_REGISTRY_PUBLIC_USERNAME }} + registry_password: ${{ secrets.OCI_LIMBO_REGISTRY_PUBLIC_PASSWORD }} + buildkit_addr: ${{ vars.BUILDKIT_ADDRESS }} + dockerfile: ${{gitea.workspace}}/container-builder + filename: ubuntu-fatboy.Dockerfile + context: ${{gitea.workspace}}/container-builder \ No newline at end of file diff --git a/README.md b/README.md index 7a899b4..58b26b7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This devcontainer is built on **mcr.microsoft.com/devcontainers/base:jammy** and I currently use it across all my infrastructure projects — from Kubernetes clusters to CI/CD pipelines — and even drop it into running pods when I need to trace or debug issues directly in‑situ. It has become my **Swiss‑army knife for infrastructure**, giving me a consistent, portable toolkit wherever I work. -## 🚀 Usage +### 🚀 Usage You can consume this DevOps base environment in two ways: @@ -105,7 +105,6 @@ This project includes a Dev Container configuration to provide a fully reproduci - A clean, isolated workspace that does not affect the host - Deterministic builds and predictable behavior across machines - **How to Use It:** 1. Install the Dev Containers extension in VS Code @@ -114,3 +113,12 @@ This project includes a Dev Container configuration to provide a fully reproduci - Reopen in Container 1. The container will build automatically and your development environment will be ready +## podman - devcontainers + +### podman-ubuntu-fatboy + +if problems building, execute `DOCKER_BUILDKIT=0` with. + +``` bash + DOCKER_BUILDKIT=0 docker build --pull --rm -f 'podman/ubuntu-fatboy.Dockerfile' -t 'podman-dev:latest' 'podman' +``` diff --git a/container-builder/assets/.zshrc b/container-builder/assets/.zshrc new file mode 100644 index 0000000..84fb704 --- /dev/null +++ b/container-builder/assets/.zshrc @@ -0,0 +1,8 @@ +export ZSH="$HOME/.oh-my-zsh" +DISABLE_AUTO_UPDATE=true +DISABLE_UPDATE_PROMPT=true +ZSH_COLORIZE_TOOL=chroma +export FAST_HIGHLIGHT_CHROMA=1 +ZSH_THEME="gnzh" +plugins=(git timer web-search ssh colorize fast-syntax-highlighting) +source $ZSH/oh-my-zsh.sh diff --git a/container-builder/templates/devcontainer.json b/container-builder/templates/devcontainer.json new file mode 100644 index 0000000..39ef93e --- /dev/null +++ b/container-builder/templates/devcontainer.json @@ -0,0 +1,34 @@ +{ + "image": "oci.limbosolutions.com/public/devcontainers/container-builder:ubuntu-fatboy-latest", + "remoteUser": "code", + "name": "container-builder-ubuntu-fatboy-latest-dev", + "runArgs": [ + "--hostname=container-builder-ubuntu-fatboy-latest-dev" + ], + "mounts": [ + "source=${localEnv:HOME}/.gitconfig,target=/home/code/.gitconfig,type=bind", + "source=${localEnv:HOME}/.ssh,target=/home/code/.ssh,type=bind" + // "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" + ], + "remoteEnv": { + "DOCKER_HOST": "ssh://user@host" + }, + "customizations": { + "vscode": { + "extensions": [ + "stateful.runme", + "yzhang.markdown-all-in-one", + "davidanson.vscode-markdownlint", + "eamodio.gitlens", + "m4ns0ur.base64", + "rogalmic.bash-debug", + "streetsidesoftware.code-spell-checker", + "ms-azuretools.vscode-containers", + "eamodio.gitlens", + "shd101wyy.markdown-preview-enhanced", + "bierner.markdown-mermaid", + "bierner.markdown-preview-github-styles" + ] + } + } +} diff --git a/container-builder/ubuntu-fatboy.Dockerfile b/container-builder/ubuntu-fatboy.Dockerfile new file mode 100644 index 0000000..b4fc5a9 --- /dev/null +++ b/container-builder/ubuntu-fatboy.Dockerfile @@ -0,0 +1,99 @@ +FROM ubuntu:latest + +ENV DEBIAN_FRONTEND=noninteractive + +# Base packages +RUN apt-get update && apt-get install -y \ + nano \ + curl \ + wget \ + git \ + sudo \ + python3 \ + python3-venv \ + python3-pip \ + jq \ + ca-certificates \ + software-properties-common \ + rclone \ + rsync \ + iputils-ping \ + dnsutils \ + iproute2 \ + traceroute \ + mtr \ + netcat-openbsd \ + nmap \ + apache2-utils \ + age \ + podman \ + zsh \ + && rm -rf /var/lib/apt/lists/* + +# set user with zsh as default shell using default user ubuntu uid +RUN usermod -l code ubuntu && \ + groupmod -n code ubuntu && \ + usermod -d /home/code -m -s /usr/bin/zsh code && \ + echo "code ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + +# Install Oh-My-Zsh for user +RUN su code -c "curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh -s -- --unattended" + +# --- Python virtual environment --- +RUN python3 -m venv /usr/local/pyenv \ + && /usr/local/pyenv/bin/pip install --upgrade pip \ + && /usr/local/pyenv/bin/pip install pyyaml +# Make virtualenv the default Python +#ENV PATH="/usr/local/pyenv/bin:${PATH}" + +# --- Install yq --- +RUN wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 \ + -O /usr/bin/yq && chmod +x /usr/bin/yq + +#Install docker +RUN curl -fsSL https://get.docker.com -o get-docker.sh \ + && sh get-docker.sh \ + && rm get-docker.sh && \ + usermod -aG docker code + + +# Install Node.js 22.x +RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ + && apt-get install -y --no-install-recommends nodejs \ + && npm cache clean --force + +# ---zsh plugins --- +RUN su code -c "git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git \ + /home/code/.oh-my-zsh/custom/plugins/fast-syntax-highlighting" + +RUN su code -c "git clone https://github.com/zsh-users/zsh-autosuggestions \ + /home/code/.oh-my-zsh/custom/plugins/zsh-autosuggestions" + +# -- install chroma for zsh +RUN mkdir /tmp/chroma \ + && curl -s https://api.github.com/repos/alecthomas/chroma/releases/latest \ + | grep "browser_download_url.*linux-amd64.*tar.gz" \ + | cut -d '"' -f 4 \ + | wget -O /tmp/chroma/chroma.tar.gz -i - \ + && tar -xzf /tmp/chroma/chroma.tar.gz -C /tmp/chroma \ + && install -m 0755 /tmp/chroma/chroma /usr/local/bin/chroma \ + && rm -r /tmp/chroma + +# --- set zsh shell as default --- +RUN chsh -s /usr/bin/zsh code + +# --- copy assets --- +COPY ./assets/.zshrc /home/code + + +#----- SOPS +ENV SOPS_VERSION=3.13.1 + +RUN wget "https://github.com/getsops/sops/releases/download/v${SOPS_VERSION}/sops-v${SOPS_VERSION}.linux.amd64" -O /tmp/sops + +RUN cp /tmp/sops /usr/local/bin/sops +RUN chmod +x /usr/local/bin/sops +RUN mkdir /workspaces && chown code:code /workspaces -R +USER code +WORKDIR /workspaces +