From 9f0c2afa3a06b355c9bad3a77d9f21bbc127478c Mon Sep 17 00:00:00 2001 From: 0xG0nz0 <8682922+0xg0nz0@users.noreply.github.com> Date: Sat, 13 Apr 2024 16:28:12 -0400 Subject: [PATCH] Initial commit of pre-built container GitHub Action (#35) --- .devcontainer/devcontainer.json | 34 +------------ .github/workflows/devcontainer-ci.yml | 49 +++++++++++++++++++ .../iggy-cpp-build/.devcontainer/Dockerfile | 4 ++ .../.devcontainer/devcontainer.json | 35 +++++++++++++ images/iggy-cpp-build/README.md | 6 +++ 5 files changed, 95 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/devcontainer-ci.yml create mode 100644 images/iggy-cpp-build/.devcontainer/Dockerfile create mode 100644 images/iggy-cpp-build/.devcontainer/devcontainer.json create mode 100644 images/iggy-cpp-build/README.md diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index aa18fe6..5a42fe2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,38 +1,6 @@ { "name": "Iggy C++ Client", - "build": { - "dockerfile": "Dockerfile" - }, - "features": { - "ghcr.io/devcontainers/features/common-utils:2": {}, - "ghcr.io/devcontainers/features/docker-in-docker:2": {}, - "ghcr.io/devcontainers/features/github-cli:1": {}, - "ghcr.io/devcontainers-contrib/features/act:1": {}, - "ghcr.io/devcontainers-contrib/features/apt-packages": { - "packages": [ - "autoconf", - "autoconf-archive", - "automake", - "build-essential", - "clang-format", - "clang-tidy", - "doxygen", - "gcovr", - "graphviz", - "lcov", - "libtool", - "ninja-build", - "python3", - "xdg-utils" - ] - }, - "ghcr.io/devcontainers-contrib/features/markdownlint-cli2:1": {}, - "ghcr.io/devcontainers-contrib/features/pre-commit:2": {}, - "ghcr.io/dhoeric/features/hadolint:1": {}, - "ghcr.io/msclock/features/vcpkg:1": { - "vcpkgversion": "stable" - } - }, + "image": "docker.io/iggyrs/iggy-cpp-build:latest", "customizations": { "vscode": { "extensions": [ diff --git a/.github/workflows/devcontainer-ci.yml b/.github/workflows/devcontainer-ci.yml new file mode 100644 index 0000000..b8e2841 --- /dev/null +++ b/.github/workflows/devcontainer-ci.yml @@ -0,0 +1,49 @@ +--- +name: devcontainer-ci + +on: + push: + paths: + - .github/workflows/devcontainer-ci.yml + - images/iggy-cpp-build/.devcontainer/* + +env: + DOCKERHUB_REGISTRY_NAME: iggyrs/iggy-cpp-build + +permissions: read-all + +jobs: + pre-build-container: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Setup Docker buildx for multi-architecture builds + uses: docker/setup-buildx-action@v3 + with: + use: true + - name: Install updated Skopeo + # This can be omitted once runner images have a version of Skopeo > 1.4.1 + # See https://github.com/containers/skopeo/issues/1874 + run: | + REPO_URL="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04" + sudo sh -c "echo 'deb ${REPO_URL}/ /' > /etc/apt/sources.list.d/skopeo.list" + curl -fsSL ${REPO_URL}/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/skopeo.gpg > /dev/null + + sudo apt update + sudo apt install skopeo + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Pre-build image + uses: devcontainers/ci@v0.3 + with: + subFolder: images/iggy-cpp-build + imageName: ${{ env.DOCKERHUB_REGISTRY_NAME }} + cacheFrom: ${{ env.DOCKERHUB_REGISTRY_NAME }} + platform: linux/amd64,linux/arm64 + push: always diff --git a/images/iggy-cpp-build/.devcontainer/Dockerfile b/images/iggy-cpp-build/.devcontainer/Dockerfile new file mode 100644 index 0000000..2b54675 --- /dev/null +++ b/images/iggy-cpp-build/.devcontainer/Dockerfile @@ -0,0 +1,4 @@ +FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-22.04 + +# workaround for msclock build issue on arm +ENV VCPKG_FORCE_SYSTEM_BINARIES=1 diff --git a/images/iggy-cpp-build/.devcontainer/devcontainer.json b/images/iggy-cpp-build/.devcontainer/devcontainer.json new file mode 100644 index 0000000..218f9e6 --- /dev/null +++ b/images/iggy-cpp-build/.devcontainer/devcontainer.json @@ -0,0 +1,35 @@ +{ + "build": { + "dockerfile": "Dockerfile" + }, + "features": { + "ghcr.io/devcontainers/features/common-utils:2": {}, + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/github-cli:1": {}, + "ghcr.io/devcontainers-contrib/features/act:1": {}, + "ghcr.io/devcontainers-contrib/features/apt-packages": { + "packages": [ + "autoconf", + "autoconf-archive", + "automake", + "build-essential", + "clang-format", + "clang-tidy", + "doxygen", + "gcovr", + "graphviz", + "lcov", + "libtool", + "ninja-build", + "python3", + "xdg-utils" + ] + }, + "ghcr.io/devcontainers-contrib/features/markdownlint-cli2:1": {}, + "ghcr.io/devcontainers-contrib/features/pre-commit:2": {}, + "ghcr.io/dhoeric/features/hadolint:1": {}, + "ghcr.io/msclock/features/vcpkg:1": { + "vcpkgversion": "stable" + } + } +} diff --git a/images/iggy-cpp-build/README.md b/images/iggy-cpp-build/README.md new file mode 100644 index 0000000..50388db --- /dev/null +++ b/images/iggy-cpp-build/README.md @@ -0,0 +1,6 @@ + +# Iggy C++ Build Container + +This directory contains the source for the pre-built devcontainer referenced in `.devcontainer` at the top level. + +Under normal circumstances you should not need to modify or load this; it gets build in a dedicated GitHub Action.