From 4d6fa737fd34de25b433f06291443440edd92d42 Mon Sep 17 00:00:00 2001 From: Mriyam Tamuli Date: Fri, 9 Feb 2024 00:57:47 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20build(devcontainer):=20Fix=20iss?= =?UTF-8?q?ue=20with=20multi-architecture=20(#140)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 👷 build(devcontainer): Update names * 👷 build(devcontainer): Build for amd64 and arm64 * 📝 docs(local): Add link to devcontainers Signed-off-by: Mriyam Tamuli --- .devcontainer/devcontainer.json | 8 +++--- .devcontainer/welcome.txt | 2 +- .github/.devcontainer/Dockerfile | 1 + .github/.devcontainer/devcontainer.json | 11 ++++++-- .../devcontainer-build-and-push.yaml | 25 ++++++++++++++++--- docs/running-locally.md | 2 +- 6 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 .github/.devcontainer/Dockerfile diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 169a22c7..3d4c7ff7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,11 +1,11 @@ // For format details, see https://containers.dev { - "name": "csi-driver-image dev container", - "image": "ghcr.io/warm-metal/csi-driver-image/devcontainer:latest", + "name": "container-image-csi-driver dev container", + "image": "ghcr.io/warm-metal/container-image-csi-driver/devcontainer:latest", // Setup the go environment and mount into the dev container at the expected location - "workspaceFolder": "/go/src/github.com/warm-metal/csi-driver-image", - "workspaceMount": "source=${localWorkspaceFolder},target=/go/src/github.com/warm-metal/csi-driver-image,type=bind,consistency=cached", + "workspaceFolder": "/go/src/github.com/warm-metal/container-image-csi-driver", + "workspaceMount": "source=${localWorkspaceFolder},target=/go/src/github.com/warm-metal/container-image-csi-driver,type=bind,consistency=cached", // Copy over welcome message "postCreateCommand": "sudo cp .devcontainer/welcome.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt" diff --git a/.devcontainer/welcome.txt b/.devcontainer/welcome.txt index 7ba0b745..18b9c34a 100644 --- a/.devcontainer/welcome.txt +++ b/.devcontainer/welcome.txt @@ -1,4 +1,4 @@ -👋 Welcome to your development environment for CSI Driver Image! +👋 Welcome to your development environment for Container Image CSI Driver! This debian dev container image contains all tools needed for development. diff --git a/.github/.devcontainer/Dockerfile b/.github/.devcontainer/Dockerfile new file mode 100644 index 00000000..88cae803 --- /dev/null +++ b/.github/.devcontainer/Dockerfile @@ -0,0 +1 @@ +FROM mcr.microsoft.com/devcontainers/base:ubuntu diff --git a/.github/.devcontainer/devcontainer.json b/.github/.devcontainer/devcontainer.json index ce3721e4..b444b86d 100644 --- a/.github/.devcontainer/devcontainer.json +++ b/.github/.devcontainer/devcontainer.json @@ -1,7 +1,14 @@ // For format details, see https://containers.dev { - "name": "csi-driver-image dev container", - "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "name": "container-image-csi-driver dev container", + // Workaround as mentioned in + // https://github.com/devcontainers/ci/issues/191#issuecomment-1473518609 + + //"image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "build": { + "dockerfile": "./Dockerfile", + "context": "." + }, "otherPortsAttributes": { "onAutoForward": "silent" diff --git a/.github/workflows/devcontainer-build-and-push.yaml b/.github/workflows/devcontainer-build-and-push.yaml index 4d6c408d..bca90391 100644 --- a/.github/workflows/devcontainer-build-and-push.yaml +++ b/.github/workflows/devcontainer-build-and-push.yaml @@ -4,11 +4,11 @@ on: push: branches: [main] paths: - - .github/workflows/devcontainer-build-and-push.yml + - .github/workflows/devcontainer-build-and-push.yaml - '.github/.devcontainer/**' pull_request: paths: - - .github/workflows/devcontainer-build-and-push.yml + - .github/workflows/devcontainer-build-and-push.yaml - '.github/.devcontainer/**' permissions: @@ -21,18 +21,35 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: linux/amd64,linux/arm64 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Log in to the GitHub Container registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - + - name: Install updated skopeo + # https://github.com/devcontainers/ci/issues/191#issuecomment-1416384710 + run: | + sudo apt purge buildah golang-github-containers-common podman skopeo + sudo apt autoremove --purge + REPO_URL="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable" + source /etc/os-release + sudo sh -c "echo 'deb ${REPO_URL}/x${NAME}_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list" + sudo wget -qnv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/x${NAME}_${VERSION_ID}/Release.key -O Release.key + sudo apt-key add Release.key + sudo apt-get update + sudo apt-get install skopeo -y - name: Pre-build dev container image uses: devcontainers/ci@v0.3 with: subFolder: .github imageName: ghcr.io/${{ github.repository }}/devcontainer cacheFrom: ghcr.io/${{ github.repository }}/devcontainer + platform: linux/amd64,linux/arm64 push: always diff --git a/docs/running-locally.md b/docs/running-locally.md index 2bfbbc6a..aecae44c 100644 --- a/docs/running-locally.md +++ b/docs/running-locally.md @@ -7,7 +7,7 @@ You have two options: ## Development Container -The development container contains all the tools necessary to work with container-image-csi-driver. +The [development container](https://containers.dev) contains all the tools necessary to work with container-image-csi-driver. You can use the development container in a few different ways: