diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 14d1595..eae1e24 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -16,8 +16,5 @@ } } }, - "postCreateCommand": { - "cookieninja-cruft": "pip install cruft" - }, "updateContentCommand": "npm install -g @devcontainers/cli" } diff --git a/.editorconfig b/.editorconfig index 8b4a144..8de40a7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,20 +1,3 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - # editorconfig.org root = true @@ -30,9 +13,6 @@ insert_final_newline = true indent_style = tab indent_size = 4 -[*.md] -trim_trailing_whitespace = false - [Makefile] indent_style = tab indent_size = 4 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00bf3b9..473d263 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,25 +1,10 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - name: Build on: push: branches: - - "*" + - main + tags: + - "v*.*.*" pull_request: branches: - main @@ -29,40 +14,79 @@ on: permissions: contents: write packages: write + pull-requests: read jobs: - features: - if: ${{ github.ref == 'refs/heads/main' }} + commitlint: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: '{{ "${{ secrets.GITHUB_TOKEN }}" }}' + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # fetch-depth is required + + - uses: wagoid/commitlint-github-action@v5 + + pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # fetch-depth is required - - name: Publish - uses: devcontainers/action@v1 + - name: Set up Go without go.mod + uses: actions/setup-go@v5 + if: ${{ hashFiles('go.mod') == '' }} with: - publish-features: "true" - base-path-to-features: "./features" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + check-latest: true + + - name: Set up Go with go.mod + uses: actions/setup-go@v5 + if: ${{ hashFiles('go.mod') != '' }} + with: + go-version-file: go.mod + + - uses: actions/setup-python@v5 + with: + python-version: 3.x + + - name: Setup JS + uses: actions/setup-node@v4 + with: + node-version: lts/* + + - name: Install dependencies + run: | + go install ./... || true + npm ci || true + + - uses: pre-commit/action@v3.0.1 base: runs-on: ubuntu-latest + needs: + - commitlint + - pre-commit outputs: docker_registry: ${{ steps.tags.outputs.docker_registry }} matrix: ${{ steps.tags.outputs.matrix }} tag: ${{ steps.tags.outputs.tag }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + + - name: Setup JS + uses: actions/setup-node@v4 with: - fetch-depth: 0 + node-version: lts/* - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} @@ -72,7 +96,7 @@ jobs: id: tags run: | echo "docker_registry=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" - echo "matrix={\"img\": $(jq -ncR '[inputs]' <<< $(ls -d images/*))}" >> "$GITHUB_OUTPUT" + echo "matrix={\"img\": $(jq -ncR '[inputs]' <<< $(ls -d images/* | grep -v '/base'))}" >> "$GITHUB_OUTPUT" echo "tag=$(date --iso-8601)" >> "$GITHUB_OUTPUT" - name: Install Dev Container CLI @@ -88,15 +112,29 @@ jobs: --platform=linux/amd64 \ --image-name=${{ steps.tags.outputs.docker_registry }}/base:${{ steps.tags.outputs.tag }} \ --image-name=${{ steps.tags.outputs.docker_registry }}/base:latest \ - --workspace-folder=base + --workspace-folder=images/base if [ ${{ github.ref == 'refs/heads/main' }} = "true" ]; then echo "Pushing images" docker push ${{ steps.tags.outputs.docker_registry }}/base:${{ steps.tags.outputs.tag }} docker push ${{ steps.tags.outputs.docker_registry }}/base:latest + else + echo "Saving base image" + docker save ${{ steps.tags.outputs.docker_registry }}/base:latest -o base.tar.gz fi + - name: Archive Docker image + uses: actions/upload-artifact@v4 + if: ${{ github.ref != 'refs/heads/main' }} + with: + name: docker-image + path: base.tar.gz + if-no-files-found: error + retention-days: 1 + compression-level: 0 + overwrite: true + images: runs-on: ubuntu-latest needs: @@ -104,23 +142,21 @@ jobs: strategy: matrix: ${{ fromJSON(needs.base.outputs.matrix) }} steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 + - uses: actions/checkout@v4 - - name: Set up Node - uses: actions/setup-node@v3 + - name: Setup JS + uses: actions/setup-node@v4 with: node-version: lts/* - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} @@ -136,8 +172,22 @@ jobs: npm install -g @devcontainers/cli devcontainer --version + - name: Import Docker image + uses: actions/download-artifact@v4 + if: ${{ github.ref != 'refs/heads/main' }} + with: + name: docker-image + - name: Build Dev Container run: | + if [ ${{ github.ref == 'refs/heads/main' }} = "true" ]; then + echo "Pulling image from registry" + docker pull ${{ needs.base.outputs.docker_registry }}/base + else + echo "Importing image from cache" + docker import base.tar.gz ${{ needs.base.outputs.docker_registry }}/base + fi + docker pull ${{ needs.base.outputs.docker_registry }}/${{ steps.tags.outputs.name }}:latest || true devcontainer build \ diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml deleted file mode 100644 index 8df8e1d..0000000 --- a/.github/workflows/commitlint.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -name: Commit lint -on: - - pull_request - - push -jobs: - commitlint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # fetch-depth is required - - - uses: wagoid/commitlint-github-action@v5 diff --git a/.github/workflows/update-documentation.yml b/.github/workflows/update-documentation.yml index d929572..de3a00b 100644 --- a/.github/workflows/update-documentation.yml +++ b/.github/workflows/update-documentation.yml @@ -1,20 +1,3 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - name: "Update Documentation" on: push: diff --git a/.gitignore b/.gitignore index 8be35e4..a3e7631 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,4 @@ node_modules .DS_Store Thumbs.db .commit -.devbox .envrc -output diff --git a/.vscode/settings.json b/.vscode/settings.json index 3408e6d..55294d3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,8 @@ { + "editor.formatOnSave": true, + "editor.rulers": [ + 80 + ], "yaml.schemas": { "https://json.schemastore.org/github-workflow.json": [ ".github/workflows/*.{yml,yaml}" diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index fd7d115..8c67a01 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -60,7 +60,7 @@ representative at an online or offline event. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -simon@simonemms.com. +[simon@simonemms.com]. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the diff --git a/Makefile b/Makefile index ff2d462..15adb53 100644 --- a/Makefile +++ b/Makefile @@ -16,13 +16,11 @@ DOCKER_REPO ?= ghcr.io/mrsimonemms/devcontainers IMG_DIR = images PLATFORM ?= linux/amd64 +all: build-all + build-all: @$(MAKE) install-devcontainers - @if ! command devcontainer --version; then \ - npm i -g @devcontainers/cli; \ - fi - @$(MAKE) build-base build-images .PHONY: build-all @@ -34,11 +32,11 @@ build: .PHONY: build build-base: - $(MAKE) build IMG_NAME="base" CONTEXT="base" + $(MAKE) build IMG_NAME="base" CONTEXT="${IMG_DIR}/base" .PHONY: build-base build-images: - @for img_path in $(shell ls -d ${IMG_DIR}/*); do \ + @for img_path in $(shell ls -d ${IMG_DIR}/* | grep -v '/base'); do \ name=$$(echo $${img_path} | sed "s/${IMG_DIR}\///"); \ \ $(MAKE) build IMG_NAME="$${name}" CONTEXT="$${img_path}"; \ @@ -51,11 +49,3 @@ install-devcontainers: npm i -g @devcontainers/cli; \ fi .PHONY: install-devcontainers - -cruft-update: -ifeq (,$(wildcard .cruft.json)) - @echo "Cruft not configured" -else - @cruft check || cruft update --skip-apply-ask --refresh-private-variables -endif -.PHONY: cruft-update diff --git a/README.md b/README.md index e2c77b1..60c797e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Dev Containers -Prebuilt Dev Container images +Pre-build [Development Containers](https://containers.dev/) @@ -11,7 +11,6 @@ Prebuilt Dev Container images * [Full](#full) * [Usage](#usage) * [Contributing](#contributing) - * [Open in Gitpod](#open-in-gitpod) * [Open in a container](#open-in-a-container) @@ -20,10 +19,7 @@ Prebuilt Dev Container images ## Purpose -This replicates the [Gitpod workspace images](https://www.gitpod.io/docs/configure/workspaces/workspace-image) -in [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers). -The replaces a commercial product with a free piece of software and takes advantage -of truly local development. +This is a series of pre-built Devcontainer image to allow local development. ## Features @@ -37,26 +33,36 @@ There are a number of images that exist. > `ghcr.io/mrsimonemms/devcontainers/base` -This provides a like-for-like mirror of [gitpod/workspace-base](https://github.com/gitpod-io/workspace-images/tree/main/base). -This is an Ubuntu image with not much installed except the base packages. If you -want to have a small Dev Container image, use this image. +This provides a base image to use for all your development environment need. +This is an Ubuntu image with sensible defaults, including +[the best-looking Git diffs](https://github.com/so-fancy/diff-so-fancy), +Docker support, tab-completion and useful Git aliases. ### Full > `ghcr.io/mrsimonemms/devcontainers/full` -This provides a like-for-like mirror of [gitpod/workspace-full](https://github.com/gitpod-io/workspace-images/tree/main/chunks), -which is the default image on all Gitpod workspaces. This uses the supported -Dev Container [features](https://containers.dev/features) instead of custom-built -image chunks like Gitpod. The advantage of using this image is that the features -are pre-built which shifts the build effort into GitHub Actions rather than on -your local machine. +An image with some modern tooling installed. -See the [devcontainer.json](/images/full/.devcontainer/devcontainer.json) for -a full list of features. +* [Go](https://github.com/devcontainers/features/tree/main/src/go) ✅ +* [Homebrew](https://github.com/meaningful-ooo/devcontainer-features/tree/main/src/homebrew) + ✅ +* [Kubernetes, Helm and Minikube](https://github.com/devcontainers/features/tree/main/src/kubectl-helm-minikube) + ✅ +* [Kubectx](https://github.com/devcontainers-contrib/features/tree/main/src/kubectx-kubens) + ✅ +* [K9s](https://github.com/rio/features/tree/main/src/k9s) ✅ +* [Nix](https://github.com/devcontainers/features/tree/main/src/nix) ✅ +* [Node.js](https://github.com/devcontainers/features/tree/main/src/node) ✅ +* [Pre-Commit](https://github.com/devcontainers-contrib/features/tree/main/src/pre-commit) + ✅ +* [Python](https://github.com/devcontainers/features/tree/main/src/python) ✅ -This also installs and supports Minikube, something which is still not possible -in Gitpod, despite a [lot of work being done](https://github.com/gitpod-io/gitpod/issues/4889). +The advantage of using this image is that the features are pre-built which shifts +the build effort into GitHub Actions rather than on your local machine. + +This can be easily extended with additional features by adding them to your +`.devcontainer/devcontainer.json` file. ## Usage @@ -65,7 +71,7 @@ this would be by specifying the `image` in your `devcontainer.json` file: ```json { - "name": "example", + "name": "devcontainer", "image": "ghcr.io/mrsimonemms/devcontainers/full" } ``` @@ -74,10 +80,6 @@ As this image is pre-built, it will vastly speed up your workflow. ## Contributing -### Open in Gitpod - -* [Open in Gitpod](https://gitpod.io/from-referrer/) - ### Open in a container * [Open in a container](https://code.visualstudio.com/docs/devcontainers/containers) diff --git a/features/cobra-cli/README.md b/features/cobra-cli/README.md index c521de2..1d450ee 100644 --- a/features/cobra-cli/README.md +++ b/features/cobra-cli/README.md @@ -1,4 +1,3 @@ - # Cobra CLI (cobra-cli) Install the Cobra CLI diff --git a/features/cobra-cli/devcontainer-feature.json b/features/cobra-cli/devcontainer-feature.json index 11991ae..e086af2 100644 --- a/features/cobra-cli/devcontainer-feature.json +++ b/features/cobra-cli/devcontainer-feature.json @@ -8,8 +8,8 @@ "version": { "type": "string", "proposals": [ - "latest", - "v1.3.0" + "latest", + "v1.3.0" ], "default": "latest", "description": "Select the version you would like to install"