Skip to content

Commit

Permalink
Update release ci approach to use a single docker build step
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Dec 1, 2023
1 parent 6dd5d12 commit 96c6edc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 65 deletions.
73 changes: 23 additions & 50 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,30 @@ jobs:
files: |
${{ steps.artifacts.outputs.file_name }}
# We move binaries so they match $TARGETPLATFORM in the Docker build
- name: Move Binaries
run: |
mkdir -p linux/amd64 linux/arm64
mv target/x86_64-unknown-linux-gnu/release/katana linux/amd64/
mv target/x86_64-unknown-linux-gnu/release/sozo linux/amd64/
mv target/x86_64-unknown-linux-gnu/release/torii linux/amd64/
mv target/aarch64-unknown-linux-gnu/release/katana linux/arm64/
mv target/aarch64-unknown-linux-gnu/release/sozo linux/arm64/
mv target/aarch64-unknown-linux-gnu/release/torii linux/arm64/
shell: bash

# Upload these for use with the Docker build later
- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: binaries
path: |
target/x86_64-unknown-linux-gnu/release/katana
target/x86_64-unknown-linux-gnu/release/sozo
target/x86_64-unknown-linux-gnu/release/torii
target/aarch64-unknown-linux-gnu/release/katana
target/aarch64-unknown-linux-gnu/release/sozo
target/aarch64-unknown-linux-gnu/release/torii
linux/amd64/katana
linux/amd64/sozo
linux/amd64/torii
linux/arm64/katana
linux/arm64/sozo
linux/arm64/torii
retention-days: 1

cleanup:
Expand Down Expand Up @@ -232,8 +244,8 @@ jobs:
const prunePrereleases = require('./.github/scripts/prune-prereleases.js')
await prunePrereleases({github, context})
docker-build-and-push-linux-amd64:
name: Build and push linux-amd64 docker image
docker-build-and-push:
name: Build and push docker image
runs-on: ubuntu-latest-4-cores
needs: [prepare, release]

Expand All @@ -245,7 +257,7 @@ jobs:
uses: actions/download-artifact@v3
with:
name: binaries
path: artifacts
path: artifacts/linux

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand All @@ -258,49 +270,10 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v3
with:
build-contexts: |
artifacts=artifacts
push: true
provenance: false
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ needs.prepare.outputs.tag_name }}
platforms: linux/amd64
target: amd64

docker-build-and-push-linux-arm64:
name: Build and push linux-arm64 docker image
runs-on: ubuntu-latest-4-cores
needs: [prepare, release]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Download binaries
uses: actions/download-artifact@v3
with:
name: binaries
path: artifacts

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push docker image
uses: docker/build-push-action@v4
with:
push: true
provenance: false
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ needs.prepare.outputs.tag_name }}
platforms: linux/arm64
target: arm64
platforms: linux/amd64,linux/arm64
build-contexts: |
artifacts=artifacts
20 changes: 5 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
FROM debian:bookworm-slim as base

ARG TARGETPLATFORM

LABEL description="Dojo is a provable game engine and toolchain for building onchain games and autonomous worlds with Cairo" \
authors="tarrence <[email protected]>" \
source="https://github.com/dojoengine/dojo" \
documentation="https://book.dojoengine.org/"

FROM base as amd64

COPY --from=artifacts x86_64-unknown-linux-gnu/release/katana /usr/local/bin/katana
COPY --from=artifacts x86_64-unknown-linux-gnu/release/sozo /usr/local/bin/sozo
COPY --from=artifacts x86_64-unknown-linux-gnu/release/torii /usr/local/bin/torii

RUN chmod +x /usr/local/bin/katana \
&& chmod +x /usr/local/bin/sozo \
&& chmod +x /usr/local/bin/torii

FROM base as arm64

COPY --from=artifacts aarch64-unknown-linux-gnu/release/katana /usr/local/bin/katana
COPY --from=artifacts aarch64-unknown-linux-gnu/release/sozo /usr/local/bin/sozo
COPY --from=artifacts aarch64-unknown-linux-gnu/release/torii /usr/local/bin/torii
COPY --from=artifacts $TARGETPLATFORM/katana /usr/local/bin/katana
COPY --from=artifacts $TARGETPLATFORM/sozo /usr/local/bin/sozo
COPY --from=artifacts $TARGETPLATFORM/torii /usr/local/bin/torii

RUN chmod +x /usr/local/bin/katana \
&& chmod +x /usr/local/bin/sozo \
Expand Down

0 comments on commit 96c6edc

Please sign in to comment.