From 0eda6492fae217afecc28c00360433d774ed75c3 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Tue, 23 Jan 2024 15:13:19 -0500 Subject: [PATCH] feat: more improvements to devcontainer and arm64 (#1242) Signed-off-by: Devin Buhl --- .devcontainer/ci/Dockerfile | 2 + .devcontainer/ci/devcontainer.json | 6 ++- .../ci/features/devcontainer-feature.json | 4 +- .devcontainer/ci/features/install.sh | 37 ++++++++++--------- .devcontainer/devcontainer.json | 1 + .github/workflows/devcontainer.yaml | 23 +++++++----- .github/workflows/e2e.yaml | 19 ---------- README.md | 20 ++++++---- 8 files changed, 55 insertions(+), 57 deletions(-) create mode 100644 .devcontainer/ci/Dockerfile diff --git a/.devcontainer/ci/Dockerfile b/.devcontainer/ci/Dockerfile new file mode 100644 index 00000000..96001075 --- /dev/null +++ b/.devcontainer/ci/Dockerfile @@ -0,0 +1,2 @@ +#Ref: https://github.com/devcontainers/ci/issues/191 +FROM mcr.microsoft.com/devcontainers/base:alpine diff --git a/.devcontainer/ci/devcontainer.json b/.devcontainer/ci/devcontainer.json index b6ac0502..b38aa2b5 100644 --- a/.devcontainer/ci/devcontainer.json +++ b/.devcontainer/ci/devcontainer.json @@ -1,6 +1,10 @@ { + "$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.schema.json", "name": "Flux Cluster Template (CI)", - "image": "mcr.microsoft.com/devcontainers/base:alpine", + "build": { + "dockerfile": "./Dockerfile", + "context": "." + }, "features": { "./features": {} }, diff --git a/.devcontainer/ci/features/devcontainer-feature.json b/.devcontainer/ci/features/devcontainer-feature.json index 1b474c55..a92190c9 100644 --- a/.devcontainer/ci/features/devcontainer-feature.json +++ b/.devcontainer/ci/features/devcontainer-feature.json @@ -1,6 +1,6 @@ { - "name": "Flux Cluster Template (Dev Tooling)", + "name": "Flux Cluster Template (Tools)", "id": "flux-cluster-template", "version": "1.0.0", - "description": "Install Development Tools" + "description": "Install Tools" } diff --git a/.devcontainer/ci/features/install.sh b/.devcontainer/ci/features/install.sh index 91b28dbb..3c44acd6 100644 --- a/.devcontainer/ci/features/install.sh +++ b/.devcontainer/ci/features/install.sh @@ -1,9 +1,11 @@ #!/bin/sh +set -e +set -o noglob ARCH="$(uname -m)" -if [ "$ARCH" == "x86_64" ]; then +if [ "$ARCH" = "x86_64" ]; then ARCH="amd64" -elif [ "$ARCH" == "aarch64" ]; then +elif [ "$ARCH" = "aarch64" ]; then ARCH="arm64" fi @@ -13,29 +15,30 @@ fi apk add --no-cache \ bash bind-tools ca-certificates curl python3 \ - py3-pip moreutils jq git \ - openssh-client + py3-pip moreutils jq git iputils \ + openssh-client apk add --no-cache \ --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community \ - age direnv fish github-cli \ - go-task helm k0sctl kubectl \ - kustomize sops yq - -apk add --no-cache \ - --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing \ - cilium-cli flux stern - -# Naming things is hard -ln -s /usr/bin/go-task /usr/local/bin/task + age direnv fish helm kubectl kustomize sops yq # # Install Tools not in Alpine Repositories # -curl https://i.jpillora.com/cloudflare/cloudflared! | sudo bash -curl https://i.jpillora.com/budimanjojo/talhelper! | sudo bash -curl https://i.jpillora.com/yannh/kubeconform! | sudo bash +for installer_path in \ + "budimanjojo/talhelper!" \ + "cilium/cilium-cli!!?as=cilium" \ + "cli/cli!!?as=gh" \ + "cloudflare/cloudflared!" \ + "fluxcd/flux2!!?as=flux" \ + "go-task/task!" \ + "k0sproject/k0sctl!" \ + "stern/stern!" \ + "yannh/kubeconform!" +do + curl -fsSL "https://i.jpillora.com/${installer_path}" | bash +done curl -fsSL -o /usr/local/bin/talosctl \ "https://github.com/siderolabs/talos/releases/latest/download/talosctl-linux-${ARCH}" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8631919d..d73602a2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,4 +1,5 @@ { + "$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.schema.json", "name": "Flux Cluster Template", "image": "ghcr.io/onedr0p/flux-cluster-template/devcontainer:base", "postCreateCommand": { diff --git a/.github/workflows/devcontainer.yaml b/.github/workflows/devcontainer.yaml index 234cff9e..992c6b90 100644 --- a/.github/workflows/devcontainer.yaml +++ b/.github/workflows/devcontainer.yaml @@ -5,10 +5,10 @@ on: workflow_dispatch: push: branches: ["main"] - paths: [".devcontainer/ci/devcontainer.json"] + paths: [".devcontainer/ci/**"] pull_request: branches: ["main"] - paths: [".devcontainer/ci/devcontainer.json"] + paths: [".devcontainer/ci/**"] schedule: - cron: "0 0 * * 1" @@ -18,7 +18,7 @@ concurrency: jobs: devcontainer: - name: Publish devcontainer + name: publish runs-on: ubuntu-latest permissions: contents: read @@ -27,13 +27,13 @@ jobs: - name: Checkout uses: actions/checkout@v4 - # - name: Set up QEMU - # uses: docker/setup-qemu-action@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - # - name: Set up Docker Buildx - # uses: docker/setup-buildx-action@v3 - # with: - # platforms: linux/amd64,linux/arm64 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + platforms: linux/amd64,linux/arm64 - if: ${{ github.event_name != 'pull_request' }} name: Login to GitHub Container Registry @@ -45,9 +45,12 @@ jobs: - name: Build and push uses: devcontainers/ci@v0.3 + env: + BUILDX_NO_DEFAULT_ATTESTATIONS: true with: imageName: ghcr.io/${{ github.repository }}/devcontainer + cacheFrom: ghcr.io/${{ github.repository }}/devcontainer imageTag: base,latest - # platform: linux/amd64,linux/arm64 + platform: linux/amd64,linux/arm64 configFile: .devcontainer/ci/devcontainer.json push: ${{ github.event_name == 'pull_request' && 'never' || 'always' }} diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 700745aa..79b747b9 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -11,25 +11,6 @@ concurrency: cancel-in-progress: true jobs: - yay: - name: workstation (yay) - runs-on: ubuntu-latest - container: - image: greyltc/archlinux-aur:yay - options: --user root - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Test Arch dependencies - shell: bash - run: >- - sudo -E -u ab -D~ bash -c ' - cd $GITHUB_WORKSPACE; - yay -Syu --needed --noconfirm --noprogressbar go-task; - go-task workstation:yay - ' - configure: name: configure runs-on: ubuntu-latest diff --git a/README.md b/README.md index 2bf17c26..9c1fd19a 100644 --- a/README.md +++ b/README.md @@ -158,17 +158,23 @@ Once you have installed Talos or Debian on your nodes, there are six stages to g 3. Continue on to 🌱 [**Stage 2**](#-stage-2-setup-your-local-workstation-environment) -### 🌱 Stage 2: Setup your local workstation environment +### 🌱 Stage 2: Setup your local workstation + +#### devcontainer + +1. The included `devcontainer` has all the required CLI tools installed all setup and ready to go. Open your repository in VSCode and switch to it. + +2. Continue on to 🔧 [**Stage 3**](#-stage-3-do-bootstrap-configuration) + +#### Non-devcontainer 1. Install the most recent version of [task](https://taskfile.dev/), see the [installation docs](https://taskfile.dev/installation/) for other supported platforms. - 📍 _If using **ArchLinux** the `task` command is `go-task` in your shell_ - ```sh # Homebrew brew install go-task # or, Arch / yay - yay -S go-task + yay -S go-task && ln -sf /usr/bin/go-task /usr/local/bin/task ``` 2. Install the most recent version of [direnv](https://direnv.net/), see the [installation docs](https://direnv.net/docs/installation.html) for other supported platforms. @@ -182,11 +188,9 @@ Once you have installed Talos or Debian on your nodes, there are six stages to g 📍 _After `direnv` is installed be sure to **[hook it into your preferred shell](https://direnv.net/docs/hook.html)** and then run `task workstation:direnv`_ -3. Install **required** CLI tools: [age](https://github.com/FiloSottile/age), [cloudflared](https://github.com/cloudflare/cloudflared), [flux](https://toolkit.fluxcd.io/), [kubeconform](https://github.com/yannh/kubeconform), [kubectl](https://kubectl.docs.kubernetes.io/installation/), [kustomize](https://kubectl.docs.kubernetes.io/installation/), [sops](https://github.com/getsops/sops). +3. Install the additional **required** CLI tools - 📍 _[k0sctl](https://github.com/k0sproject/k0sctl) is required for k0s. [talosctl](https://www.talos.dev/latest/learn-more/talosctl/) and [talhelper](https://github.com/budimanjojo/talhelper) is required for Talos._ - - 📍 _Not using Homebrew or ArchLinux? Make sure to look up how to install the latest version of each of these CLI tools and install them._ + 📍 _**Not using Homebrew or ArchLinux?** Make sure to look up how to install the **latest** version of the CLI tools listed in the [Brewfile](.taskfiles/Workstation/Brewfile)/[Archfile](.taskfiles/Workstation/Archfile) and install them._ ```sh # Homebrew