Skip to content

Commit

Permalink
Merge pull request #56 from Layr-Labs/epociask--fix-multicontainer-build
Browse files Browse the repository at this point in the history
fix: multi platform builds
  • Loading branch information
epociask authored Dec 16, 2024
2 parents f3f080f + 928c57d commit 1577543
Showing 1 changed file with 59 additions and 29 deletions.
88 changes: 59 additions & 29 deletions .github/workflows/docker-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_dispatch:

jobs:
build-linux-amd64:
docker-amd64:
runs-on: linux-2xl

steps:
Expand All @@ -23,9 +23,9 @@ jobs:
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache-amd64
key: linux-amd64-buildx-${{ hashFiles('Dockerfile') }}
restore-keys: linux-amd64-buildx-
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }}
restore-keys: ${{ runner.os }}-buildx-

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
Expand All @@ -41,28 +41,43 @@ jobs:
images: |
ghcr.io/${{ github.repository_owner }}/nitro-eigenda
tags: |
${{ github.ref_name }}-linux-amd64
latest-linux-amd64
- name: Build and push for linux/amd64
uses: docker/build-push-action@v5
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=ref,event=tag,suffix={{sha}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=,format=short,enable=true
type=raw,value=latest,enable={{is_default_branch}}
type=match,pattern=^(v\d+\.\d+\.\d+-\w*)\..*$,value=$1,enable={{is_default_branch}}
- name: "Build and push amd64"
uses: docker/[email protected]
with:
platform: linux/amd64
target: nitro-node-dev
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache-amd64
cache-to: type=local,dest=/tmp/.buildx-cache-amd64-new,mode=max
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache-amd64
mv /tmp/.buildx-cache-amd64-new /tmp/.buildx-cache-amd64
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build-linux-arm64:
runs-on: linux-2xl
- name: Clear cache on failure
if: failure()
run: |
keys=(${{ runner.os }}-buildx- ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }})
for key in "${keys[@]}"; do
curl -X DELETE -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/caches/$key"
done
docker-arm64:
runs-on: linux-xl-arm

steps:
- name: Checkout
Expand All @@ -81,9 +96,9 @@ jobs:
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache-arm64
key: linux-arm64-buildx-${{ hashFiles('Dockerfile') }}
restore-keys: linux-arm64-buildx-
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }}
restore-keys: ${{ runner.os }}-buildx-

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
Expand All @@ -99,22 +114,37 @@ jobs:
images: |
ghcr.io/${{ github.repository_owner }}/nitro-eigenda
tags: |
${{ github.ref_name }}-linux-arm64
latest-linux-arm64
- name: Build and push for linux/arm64
uses: docker/build-push-action@v5
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=ref,event=tag,suffix={{sha}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=,format=short,enable=true
type=raw,value=latest,enable={{is_default_branch}}
type=match,pattern=^(v\d+\.\d+\.\d+-\w*)\..*$,value=$1,enable={{is_default_branch}}
- name: "Build and push arm64"
uses: docker/[email protected]
with:
platform: linux/arm64/v8
target: nitro-node-dev
context: .
platforms: linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache-arm64
cache-to: type=local,dest=/tmp/.buildx-cache-arm64-new,mode=max
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache-arm64
mv /tmp/.buildx-cache-arm64-new /tmp/.buildx-cache-arm64
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Clear cache on failure
if: failure()
run: |
keys=(${{ runner.os }}-buildx- ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }})
for key in "${keys[@]}"; do
curl -X DELETE -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/actions/caches/$key"
done

0 comments on commit 1577543

Please sign in to comment.