Skip to content

Dev Containers

Dev Containers #10

name: "Dev Containers"
on:
workflow_dispatch:
workflow_run:
workflows: ["Image"]
types: [completed]
jobs:
amd64:
name: Build AMD64 image
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
runs-on: ubuntu-24.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
# Login
# https://github.com/marketplace/actions/docker-login
- name: Login to GitHub container registry 🏭
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image for AMD64 🧪
run: |
cd "devcontainer" && \
podman build . \
--network "slirp4netns" \
--platform "linux/amd64" \
--tag "ghcr.io/cyclenerd/cloud-tools-container:dev-amd64" && \
podman push "ghcr.io/cyclenerd/cloud-tools-container:dev-amd64"
arm64:
name: Build ARM64 image
needs: [amd64]
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
runs-on: ubuntu-24.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
# Add support for more platforms with QEMU
# https://github.com/marketplace/actions/docker-setup-qemu
- name: Set up QEMU 🔧
uses: docker/setup-qemu-action@v3
with:
platforms: 'arm64'
# Login
# https://github.com/marketplace/actions/docker-login
- name: Login to GitHub container registry 🏭
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image for ARM64 🧪
run: |
cd "devcontainer" && \
podman build . \
--network "slirp4netns" \
--platform "linux/arm64" \
--tag "ghcr.io/cyclenerd/cloud-tools-container:dev-arm64" && \
podman push "ghcr.io/cyclenerd/cloud-tools-container:dev-arm64"
multi:
name: Combine images
needs: [amd64, arm64]
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
runs-on: ubuntu-24.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
# Login
# https://github.com/marketplace/actions/docker-login
- name: Login to GitHub container registry 🏭
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull platform-specific images 💿
run: |
podman pull "ghcr.io/cyclenerd/cloud-tools-container:dev-amd64" && \
podman pull "ghcr.io/cyclenerd/cloud-tools-container:dev-arm64"
- name: Create multi-platform image 💿
run: |
podman manifest create "cloud-tools-container:dev-multi" \
--amend "ghcr.io/cyclenerd/cloud-tools-container:dev-amd64" \
--amend "ghcr.io/cyclenerd/cloud-tools-container:dev-arm64" && \
podman manifest push --all "cloud-tools-container:dev-multi" "docker://ghcr.io/cyclenerd/cloud-tools-container:dev-test"
test:
name: Test image
needs: [multi]
runs-on: ubuntu-24.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
# Inspect
- name: Inspect test image 💿
run: |
skopeo inspect --raw "docker://ghcr.io/cyclenerd/cloud-tools-container:dev-test" | jq && \
skopeo inspect --raw "docker://ghcr.io/cyclenerd/cloud-tools-container:dev-test" | grep -o "amd64" && \
skopeo inspect --raw "docker://ghcr.io/cyclenerd/cloud-tools-container:dev-test" | grep -o "arm64"
# Run test
- name: Pull test image 💿
run: |
docker pull "ghcr.io/cyclenerd/cloud-tools-container:dev-test"
docker tag "ghcr.io/cyclenerd/cloud-tools-container:dev-test" "cloud-tools-container"
- name: Images 📏
run: docker images
# Tests
- name: Test 📏
run: docker run cloud-tools-container gcloud --version || exit 9
github-registry-latest:
name: Push image to GitHub
runs-on: ubuntu-24.04
needs: [test]
steps:
- name: Login to GitHub container registry 🏭
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image to GitHub container registry as latest version 🚢
run: skopeo copy --all "docker://ghcr.io/cyclenerd/cloud-tools-container:dev-test" "docker://ghcr.io/cyclenerd/cloud-tools-container:dev"