diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4a14f85788..7ffb60d857 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -81,6 +81,10 @@ jobs: name: ${{ matrix.job.target }} (${{ matrix.job.os }}) needs: prepare runs-on: ${{ matrix.job.os }} + env: + PLATFORM_NAME: ${{ matrix.job.platform }} + TARGET: ${{ matrix.job.target }} + ARCH: ${{ matrix.job.arch }} strategy: matrix: job: @@ -148,9 +152,6 @@ jobs: - name: Archive binaries id: artifacts env: - PLATFORM_NAME: ${{ matrix.job.platform }} - TARGET: ${{ matrix.job.target }} - ARCH: ${{ matrix.job.arch }} VERSION_NAME: ${{ (env.IS_NIGHTLY == 'true' && 'nightly') || needs.prepare.outputs.tag_name }} run: | if [ "$PLATFORM_NAME" == "linux" ]; then @@ -193,18 +194,27 @@ jobs: files: | ${{ steps.artifacts.outputs.file_name }} + # We move binaries so they match $TARGETPLATFORM in the Docker build + - name: Move Binaries + run: | + mkdir -p $PLATFORM_NAME/$ARCH + mv target/$TARGET/release/katana $PLATFORM_NAME/$ARCH + mv target/$TARGET/release/sozo $PLATFORM_NAME/$ARCH + mv target/$TARGET/release/torii $PLATFORM_NAME/$ARCH + 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: @@ -232,8 +242,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] @@ -245,7 +255,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 @@ -258,49 +268,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 - diff --git a/Dockerfile b/Dockerfile index 5d959e7fa8..18c996cead 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 " \ 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 \