Skip to content

Commit

Permalink
πŸ‘· build(devcontainer): Fix issue with multi-architecture (#140)
Browse files Browse the repository at this point in the history
* πŸ‘· build(devcontainer): Update names
* πŸ‘· build(devcontainer): Build for amd64 and arm64
* πŸ“ docs(local): Add link to devcontainers

Signed-off-by: Mriyam Tamuli <[email protected]>
  • Loading branch information
mbtamuli authored Feb 8, 2024
1 parent 98d1b98 commit 4d6fa73
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 12 deletions.
8 changes: 4 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/welcome.txt
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
1 change: 1 addition & 0 deletions .github/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM mcr.microsoft.com/devcontainers/base:ubuntu
11 changes: 9 additions & 2 deletions .github/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
25 changes: 21 additions & 4 deletions .github/workflows/devcontainer-build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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/[email protected]
with:
subFolder: .github
imageName: ghcr.io/${{ github.repository }}/devcontainer
cacheFrom: ghcr.io/${{ github.repository }}/devcontainer
platform: linux/amd64,linux/arm64
push: always
2 changes: 1 addition & 1 deletion docs/running-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit 4d6fa73

Please sign in to comment.