build(nix): use docker arch names for container

This commit is contained in:
seth 2024-08-07 00:03:51 -04:00 committed by Sefa Eyeoglu
parent bcac15ebad
commit 3ca7323414
2 changed files with 19 additions and 15 deletions

View file

@ -2,21 +2,24 @@ name: Docker
on: on:
push: push:
branches: ['main'] branches: [ main ]
pull_request: pull_request:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build: build:
name: Build image name: Build image
runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false
matrix: matrix:
arch: [x86_64, aarch64] arch: [ amd64, arm64 ]
runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix - name: Install Nix
uses: DeterminateSystems/nix-installer-action@v15 uses: DeterminateSystems/nix-installer-action@v15
@ -43,8 +46,10 @@ jobs:
push: push:
name: Push image name: Push image
needs: build needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
@ -54,16 +59,15 @@ jobs:
REGISTRY: ghcr.io REGISTRY: ghcr.io
USERNAME: ${{ github.actor }} USERNAME: ${{ github.actor }}
if: github.event_name == 'push'
steps: steps:
- uses: actions/checkout@v4 - name: Checkout repository
uses: actions/checkout@v4
- name: Determine image name - name: Determine image name
run: | run: |
echo "IMAGE_NAME=${REPOSITORY,,}" >> "$GITHUB_ENV" echo "IMAGE_NAME=${REPOSITORY,,}" >> "$GITHUB_ENV"
env: env:
REPOSITORY: '${{ github.repository }}' REPOSITORY: ${{ github.repository }}
- name: Download images - name: Download images
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
@ -83,15 +87,15 @@ jobs:
run: | run: |
set -eu set -eu
architectures=("x86_64" "aarch64") architectures=("amd64" "arm64")
for arch in "${architectures[@]}"; do for arch in "${architectures[@]}"; do
docker load < images/container-"$arch"/*.tar.gz docker load < images/container-"$arch"/*.tar.gz
docker tag refraction:latest-"$arch" "$TAG"-"$arch" docker tag refraction:latest-"$arch" "$TAG"-"$arch"
docker push ${{ env.TAG }}-"$arch" docker push "$TAG"-"$arch"
done done
docker manifest create "$TAG" \ docker manifest create "$TAG" \
--amend "$TAG"-x86_64 \ --amend "$TAG"-amd64 \
--amend "$TAG"-aarch64 --amend "$TAG"-arm64
docker manifest push "$TAG" docker manifest push "$TAG"

View file

@ -89,8 +89,8 @@
static-x86_64 = mkStatic { arch = "x86_64"; }; static-x86_64 = mkStatic { arch = "x86_64"; };
static-aarch64 = mkStatic { arch = "aarch64"; }; static-aarch64 = mkStatic { arch = "aarch64"; };
container-x86_64 = containerize packages'.static-x86_64; container-amd64 = containerize packages'.static-x86_64;
container-aarch64 = containerize packages'.static-aarch64; container-arm64 = containerize packages'.static-aarch64;
default = packages'.refraction; default = packages'.refraction;
} }