From 6c6b40df922d567f442fe263e9569d1c988f6159 Mon Sep 17 00:00:00 2001 From: steebchen Date: Tue, 17 Sep 2024 15:28:40 -0400 Subject: [PATCH 01/32] Add GitHub Actions workflow for Docker builds and deployment This commit introduces a new GitHub Actions workflow file, `preview.yml`, to automate building and deploying Docker images. The workflow includes steps for setting up the Rust toolchain, building binaries, archiving artifacts, and deploying them via Docker and Slot. This enhancement streamlines the CI/CD process, ensuring consistency and efficiency in releases. --- .github/workflows/preview.yml | 137 ++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 .github/workflows/preview.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000000..7b0ac7b520 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,137 @@ +name: preview + +on: + workflow_dispatch: + push: + branches: + - ci-preview + +env: + CARGO_TERM_COLOR: always + RUST_VERSION: 1.80.0 + REGISTRY_IMAGE: ghcr.io/${{ github.repository }} + +jobs: + build: + name: ${{ matrix.job.target }} (${{ matrix.job.os }}) + runs-on: ${{ matrix.job.os }} + env: + PLATFORM_NAME: ${{ matrix.job.platform }} + TARGET: ${{ matrix.job.target }} + ARCH: ${{ matrix.job.arch }} + strategy: + matrix: + job: + - os: ubuntu-latest-4-cores + platform: linux + target: x86_64-unknown-linux-gnu + arch: amd64 + + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@master + name: Rust Toolchain Setup + with: + targets: ${{ matrix.job.target }} + toolchain: ${{ env.RUST_VERSION }} + + - uses: Swatinem/rust-cache@v1 + + - uses: arduino/setup-protoc@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: "25.x" + + - name: Build binaries + run: | + cargo build -r --bin katana --target ${{ matrix.job.target }} + cargo build -r --bin torii --target ${{ matrix.job.target }} + cargo build -r --bin saya --target ${{ matrix.job.target }} + + - name: Archive binaries + id: artifacts + env: + VERSION_NAME: v${{ needs.prepare.outputs.tag_name }} + run: | + tar -czvf "dojo_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release katana torii saya + echo "file_name=dojo_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT + shell: bash + + # We move binaries so they match $TARGETPLATFORM in the Docker build + - name: Move Binaries + if: ${{ env.PLATFORM_NAME == 'linux' }} + run: | + mkdir -p $PLATFORM_NAME/$ARCH + mv target/$TARGET/release/katana $PLATFORM_NAME/$ARCH + mv target/$TARGET/release/torii $PLATFORM_NAME/$ARCH + mv target/$TARGET/release/saya $PLATFORM_NAME/$ARCH + shell: bash + + # Upload these for use with the Docker build later + - name: Upload docker binaries + uses: actions/upload-artifact@v3 + with: + name: binaries + path: ${{ env.PLATFORM_NAME }} + retention-days: 1 + + - name: Upload release artifacts + uses: actions/upload-artifact@v3 + with: + name: artifacts + path: ${{ steps.artifacts.outputs.file_name }} + retention-days: 1 + + docker-build-and-push: + runs-on: ubuntu-20.04-4-cores + needs: [build] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Download binaries + uses: actions/download-artifact@v3 + with: + name: binaries + path: artifacts/linux + + - 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@v3 + with: + push: true + tags: ghcr.io/${{ github.repository }}:preview--${{ github.ref_name }} + platforms: linux/amd64 + build-contexts: | + artifacts=artifacts + + deploy: + runs-on: ubuntu-latest + needs: [docker-build-and-push] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Deploy on slot + run: | + curl -L https://slot.cartridge.sh | bash + slotup + slot --version + slot d create preview--${{ github.ref_name }} katana --version preview--${{ github.ref_name }} + slot d create preview--${{ github.ref_name }} torii --version preview--${{ github.ref_name }} \ + --rpc=http://slot.prod.svc.cluster.local/x/starknet/sepolia \ + --world=0x1caef8b56b3f0627479ab624eefff92d7d8e1daa9d418cc76bd74935f1dc283 \ + --start-block=0 + env: + SLOT_AUTH: ${{ secrets.SLOT_AUTH }} From 26ad01448745479c4644d1110d294fefdd437a75 Mon Sep 17 00:00:00 2001 From: steebchen Date: Tue, 17 Sep 2024 15:49:22 -0400 Subject: [PATCH 02/32] wip --- .github/workflows/preview.yml | 59 +++++++++++------------------------ 1 file changed, 18 insertions(+), 41 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 7b0ac7b520..83b2d46a0e 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -13,29 +13,12 @@ env: jobs: build: - name: ${{ matrix.job.target }} (${{ matrix.job.os }}) - runs-on: ${{ matrix.job.os }} - env: - PLATFORM_NAME: ${{ matrix.job.platform }} - TARGET: ${{ matrix.job.target }} - ARCH: ${{ matrix.job.arch }} - strategy: - matrix: - job: - - os: ubuntu-latest-4-cores - platform: linux - target: x86_64-unknown-linux-gnu - arch: amd64 + name: Build + runs-on: ubuntu-latest-4-cores steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@master - name: Rust Toolchain Setup - with: - targets: ${{ matrix.job.target }} - toolchain: ${{ env.RUST_VERSION }} - - uses: Swatinem/rust-cache@v1 - uses: arduino/setup-protoc@v2 @@ -45,27 +28,25 @@ jobs: - name: Build binaries run: | - cargo build -r --bin katana --target ${{ matrix.job.target }} - cargo build -r --bin torii --target ${{ matrix.job.target }} - cargo build -r --bin saya --target ${{ matrix.job.target }} + cargo build -r --bin katana + cargo build -r --bin torii + cargo build -r --bin sozo - name: Archive binaries id: artifacts env: VERSION_NAME: v${{ needs.prepare.outputs.tag_name }} run: | - tar -czvf "dojo_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" -C ./target/${TARGET}/release katana torii saya - echo "file_name=dojo_${VERSION_NAME}_${PLATFORM_NAME}_${ARCH}.tar.gz" >> $GITHUB_OUTPUT + tar -czvf "dojo_${VERSION_NAME}_linux_amd64.tar.gz" -C ./target/release katana torii sozo + echo "file_name=dojo_${VERSION_NAME}_linux_amd64.tar.gz" >> $GITHUB_OUTPUT shell: bash - # We move binaries so they match $TARGETPLATFORM in the Docker build - name: Move Binaries - if: ${{ env.PLATFORM_NAME == 'linux' }} run: | - mkdir -p $PLATFORM_NAME/$ARCH - mv target/$TARGET/release/katana $PLATFORM_NAME/$ARCH - mv target/$TARGET/release/torii $PLATFORM_NAME/$ARCH - mv target/$TARGET/release/saya $PLATFORM_NAME/$ARCH + mkdir -p linux/amd64/ + mv target/release/katana linux/amd64/ + mv target/release/torii linux/amd64/ + mv target/release/sozo linux/amd64/ shell: bash # Upload these for use with the Docker build later @@ -73,18 +54,11 @@ jobs: uses: actions/upload-artifact@v3 with: name: binaries - path: ${{ env.PLATFORM_NAME }} - retention-days: 1 - - - name: Upload release artifacts - uses: actions/upload-artifact@v3 - with: - name: artifacts - path: ${{ steps.artifacts.outputs.file_name }} + path: linux/amd64/ retention-days: 1 docker-build-and-push: - runs-on: ubuntu-20.04-4-cores + runs-on: ubuntu-latest needs: [build] steps: @@ -95,7 +69,10 @@ jobs: uses: actions/download-artifact@v3 with: name: binaries - path: artifacts/linux + path: artifacts + + - name: TEMP LS + run: ls -R artifacts - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -131,7 +108,7 @@ jobs: slot d create preview--${{ github.ref_name }} katana --version preview--${{ github.ref_name }} slot d create preview--${{ github.ref_name }} torii --version preview--${{ github.ref_name }} \ --rpc=http://slot.prod.svc.cluster.local/x/starknet/sepolia \ - --world=0x1caef8b56b3f0627479ab624eefff92d7d8e1daa9d418cc76bd74935f1dc283 \ + --world=0x53b7efae79ce1d7729828bb6dee2cee09358fde4c4325805cf97678919a4855 \ --start-block=0 env: SLOT_AUTH: ${{ secrets.SLOT_AUTH }} From 662d1940d2ddb2ba94b70c62c84483158f46c569 Mon Sep 17 00:00:00 2001 From: steebchen Date: Tue, 17 Sep 2024 18:56:59 -0400 Subject: [PATCH 03/32] wip --- .github/workflows/preview.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 83b2d46a0e..bd7028ef9b 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -43,10 +43,10 @@ jobs: - name: Move Binaries run: | - mkdir -p linux/amd64/ - mv target/release/katana linux/amd64/ - mv target/release/torii linux/amd64/ - mv target/release/sozo linux/amd64/ + mkdir -p artifacts/linux/amd64/ + mv target/release/katana artifacts/linux/amd64/ + mv target/release/torii artifacts/linux/amd64/ + mv target/release/sozo artifacts/linux/amd64/ shell: bash # Upload these for use with the Docker build later @@ -54,7 +54,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: binaries - path: linux/amd64/ + path: artifacts retention-days: 1 docker-build-and-push: From 0fa007b81f095e83c88a1ecdfb494672d952da24 Mon Sep 17 00:00:00 2001 From: steebchen Date: Tue, 17 Sep 2024 22:30:30 -0400 Subject: [PATCH 04/32] fix --- .github/workflows/preview.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index bd7028ef9b..423b6e1619 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -103,6 +103,7 @@ jobs: - name: Deploy on slot run: | curl -L https://slot.cartridge.sh | bash + . $HOME/.bashrc slotup slot --version slot d create preview--${{ github.ref_name }} katana --version preview--${{ github.ref_name }} From 6605027ae6aab13efe214be1b82e551af438b6f4 Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 11:35:24 -0400 Subject: [PATCH 05/32] bin slot --- .github/workflows/preview.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 423b6e1619..8ca5610ae7 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -103,11 +103,10 @@ jobs: - name: Deploy on slot run: | curl -L https://slot.cartridge.sh | bash - . $HOME/.bashrc slotup - slot --version - slot d create preview--${{ github.ref_name }} katana --version preview--${{ github.ref_name }} - slot d create preview--${{ github.ref_name }} torii --version preview--${{ github.ref_name }} \ + $HOME/.slot/bin/slot --version + $HOME/.slot/bin/slot d create preview--${{ github.ref_name }} katana --version preview--${{ github.ref_name }} + $HOME/.slot/bin/slot d create preview--${{ github.ref_name }} torii --version preview--${{ github.ref_name }} \ --rpc=http://slot.prod.svc.cluster.local/x/starknet/sepolia \ --world=0x53b7efae79ce1d7729828bb6dee2cee09358fde4c4325805cf97678919a4855 \ --start-block=0 From c1305489e475e871f9b1badba5ae8c2ee08c051e Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 11:59:51 -0400 Subject: [PATCH 06/32] fix --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 8ca5610ae7..9c2d60dbe1 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -103,7 +103,7 @@ jobs: - name: Deploy on slot run: | curl -L https://slot.cartridge.sh | bash - slotup + $HOME/.slot/bin/slotup $HOME/.slot/bin/slot --version $HOME/.slot/bin/slot d create preview--${{ github.ref_name }} katana --version preview--${{ github.ref_name }} $HOME/.slot/bin/slot d create preview--${{ github.ref_name }} torii --version preview--${{ github.ref_name }} \ From ce3441c704fde3be2acbece8457d07d71a1b10f7 Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 13:21:31 -0400 Subject: [PATCH 07/32] temp --- .github/workflows/preview.yml | 162 +++++++++++++++++----------------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 9c2d60dbe1..254f1f5ee6 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -12,90 +12,90 @@ env: REGISTRY_IMAGE: ghcr.io/${{ github.repository }} jobs: - build: - name: Build - runs-on: ubuntu-latest-4-cores - - steps: - - uses: actions/checkout@v4 - - - uses: Swatinem/rust-cache@v1 - - - uses: arduino/setup-protoc@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - version: "25.x" - - - name: Build binaries - run: | - cargo build -r --bin katana - cargo build -r --bin torii - cargo build -r --bin sozo - - - name: Archive binaries - id: artifacts - env: - VERSION_NAME: v${{ needs.prepare.outputs.tag_name }} - run: | - tar -czvf "dojo_${VERSION_NAME}_linux_amd64.tar.gz" -C ./target/release katana torii sozo - echo "file_name=dojo_${VERSION_NAME}_linux_amd64.tar.gz" >> $GITHUB_OUTPUT - shell: bash - - - name: Move Binaries - run: | - mkdir -p artifacts/linux/amd64/ - mv target/release/katana artifacts/linux/amd64/ - mv target/release/torii artifacts/linux/amd64/ - mv target/release/sozo artifacts/linux/amd64/ - shell: bash - - # Upload these for use with the Docker build later - - name: Upload docker binaries - uses: actions/upload-artifact@v3 - with: - name: binaries - path: artifacts - retention-days: 1 - - docker-build-and-push: - runs-on: ubuntu-latest - needs: [build] - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Download binaries - uses: actions/download-artifact@v3 - with: - name: binaries - path: artifacts - - - name: TEMP LS - run: ls -R 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@v3 - with: - push: true - tags: ghcr.io/${{ github.repository }}:preview--${{ github.ref_name }} - platforms: linux/amd64 - build-contexts: | - artifacts=artifacts +# build: +# name: Build +# runs-on: ubuntu-latest-4-cores + +# steps: +# - uses: actions/checkout@v4 + +# - uses: Swatinem/rust-cache@v1 + +# - uses: arduino/setup-protoc@v2 +# with: +# repo-token: ${{ secrets.GITHUB_TOKEN }} +# version: "25.x" + +# - name: Build binaries +# run: | +# cargo build -r --bin katana +# cargo build -r --bin torii +# cargo build -r --bin sozo + +# - name: Archive binaries +# id: artifacts +# env: +# VERSION_NAME: v${{ needs.prepare.outputs.tag_name }} +# run: | +# tar -czvf "dojo_${VERSION_NAME}_linux_amd64.tar.gz" -C ./target/release katana torii sozo +# echo "file_name=dojo_${VERSION_NAME}_linux_amd64.tar.gz" >> $GITHUB_OUTPUT +# shell: bash + +# - name: Move Binaries +# run: | +# mkdir -p artifacts/linux/amd64/ +# mv target/release/katana artifacts/linux/amd64/ +# mv target/release/torii artifacts/linux/amd64/ +# mv target/release/sozo artifacts/linux/amd64/ +# shell: bash + +# # Upload these for use with the Docker build later +# - name: Upload docker binaries +# uses: actions/upload-artifact@v3 +# with: +# name: binaries +# path: artifacts +# retention-days: 1 + +# docker-build-and-push: +# runs-on: ubuntu-latest +# needs: [build] + +# steps: +# - name: Checkout repository +# uses: actions/checkout@v2 + +# - name: Download binaries +# uses: actions/download-artifact@v3 +# with: +# name: binaries +# path: artifacts + +# - name: TEMP LS +# run: ls -R 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@v3 +# with: +# push: true +# tags: ghcr.io/${{ github.repository }}:preview--${{ github.ref_name }} +# platforms: linux/amd64 +# build-contexts: | +# artifacts=artifacts deploy: runs-on: ubuntu-latest - needs: [docker-build-and-push] +# needs: [docker-build-and-push] steps: - name: Checkout repository uses: actions/checkout@v4 From 5a4bec7a06ed16a2fc054eadf186d3ba8fa863f1 Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 13:22:50 -0400 Subject: [PATCH 08/32] wip --- .github/workflows/preview.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 254f1f5ee6..2d8f8d69af 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -103,6 +103,7 @@ jobs: - name: Deploy on slot run: | curl -L https://slot.cartridge.sh | bash + ls -R $HOME/.slot $HOME/.slot/bin/slotup $HOME/.slot/bin/slot --version $HOME/.slot/bin/slot d create preview--${{ github.ref_name }} katana --version preview--${{ github.ref_name }} From 27e445cfdda901a5755ce718fe8b8b76e36ae845 Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 13:26:19 -0400 Subject: [PATCH 09/32] xdg --- .github/workflows/preview.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 2d8f8d69af..98487716c9 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -102,12 +102,12 @@ jobs: - name: Deploy on slot run: | + set -eux curl -L https://slot.cartridge.sh | bash - ls -R $HOME/.slot - $HOME/.slot/bin/slotup - $HOME/.slot/bin/slot --version - $HOME/.slot/bin/slot d create preview--${{ github.ref_name }} katana --version preview--${{ github.ref_name }} - $HOME/.slot/bin/slot d create preview--${{ github.ref_name }} torii --version preview--${{ github.ref_name }} \ + $XDG_CONFIG_HOME/.slot/bin/slotup + $XDG_CONFIG_HOME/.slot/bin/slot --version + $XDG_CONFIG_HOME/.slot/bin/slot d create preview--${{ github.ref_name }} katana --version preview--${{ github.ref_name }} + $XDG_CONFIG_HOME/.slot/bin/slot d create preview--${{ github.ref_name }} torii --version preview--${{ github.ref_name }} \ --rpc=http://slot.prod.svc.cluster.local/x/starknet/sepolia \ --world=0x53b7efae79ce1d7729828bb6dee2cee09358fde4c4325805cf97678919a4855 \ --start-block=0 From 2d4a062de82b31c28fb45b33d568cf43f26c7369 Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 16:44:35 -0400 Subject: [PATCH 10/32] short sha --- .github/workflows/preview.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 98487716c9..27554e023c 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -84,11 +84,17 @@ jobs: # username: ${{ github.actor }} # password: ${{ secrets.GITHUB_TOKEN }} +# - name: Set outputs +# id: vars +# run: | +# git config --global --add safe.directory '*' +# echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + # - name: Build and push docker image # uses: docker/build-push-action@v3 # with: # push: true -# tags: ghcr.io/${{ github.repository }}:preview--${{ github.ref_name }} +# tags: ghcr.io/${{ github.repository }}:preview--${{ steps.vars.outputs.sha_short }} # platforms: linux/amd64 # build-contexts: | # artifacts=artifacts @@ -100,14 +106,20 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Set outputs + id: vars + run: | + git config --global --add safe.directory '*' + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + - name: Deploy on slot run: | set -eux curl -L https://slot.cartridge.sh | bash $XDG_CONFIG_HOME/.slot/bin/slotup $XDG_CONFIG_HOME/.slot/bin/slot --version - $XDG_CONFIG_HOME/.slot/bin/slot d create preview--${{ github.ref_name }} katana --version preview--${{ github.ref_name }} - $XDG_CONFIG_HOME/.slot/bin/slot d create preview--${{ github.ref_name }} torii --version preview--${{ github.ref_name }} \ + $XDG_CONFIG_HOME/.slot/bin/slot d create preview--${{ steps.vars.outputs.sha_short }} katana --version preview--${{ steps.vars.outputs.sha_short }} + $XDG_CONFIG_HOME/.slot/bin/slot d create preview--${{ steps.vars.outputs.sha_short }} torii --version preview--${{ steps.vars.outputs.sha_short }} \ --rpc=http://slot.prod.svc.cluster.local/x/starknet/sepolia \ --world=0x53b7efae79ce1d7729828bb6dee2cee09358fde4c4325805cf97678919a4855 \ --start-block=0 From e9076a6233af21ee5e236f07683b538dbdfc0d5f Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 16:44:52 -0400 Subject: [PATCH 11/32] uncomment --- .github/workflows/preview.yml | 174 +++++++++++++++++----------------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 27554e023c..f165cb2948 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -12,96 +12,96 @@ env: REGISTRY_IMAGE: ghcr.io/${{ github.repository }} jobs: -# build: -# name: Build -# runs-on: ubuntu-latest-4-cores - -# steps: -# - uses: actions/checkout@v4 - -# - uses: Swatinem/rust-cache@v1 - -# - uses: arduino/setup-protoc@v2 -# with: -# repo-token: ${{ secrets.GITHUB_TOKEN }} -# version: "25.x" - -# - name: Build binaries -# run: | -# cargo build -r --bin katana -# cargo build -r --bin torii -# cargo build -r --bin sozo - -# - name: Archive binaries -# id: artifacts -# env: -# VERSION_NAME: v${{ needs.prepare.outputs.tag_name }} -# run: | -# tar -czvf "dojo_${VERSION_NAME}_linux_amd64.tar.gz" -C ./target/release katana torii sozo -# echo "file_name=dojo_${VERSION_NAME}_linux_amd64.tar.gz" >> $GITHUB_OUTPUT -# shell: bash - -# - name: Move Binaries -# run: | -# mkdir -p artifacts/linux/amd64/ -# mv target/release/katana artifacts/linux/amd64/ -# mv target/release/torii artifacts/linux/amd64/ -# mv target/release/sozo artifacts/linux/amd64/ -# shell: bash - -# # Upload these for use with the Docker build later -# - name: Upload docker binaries -# uses: actions/upload-artifact@v3 -# with: -# name: binaries -# path: artifacts -# retention-days: 1 - -# docker-build-and-push: -# runs-on: ubuntu-latest -# needs: [build] - -# steps: -# - name: Checkout repository -# uses: actions/checkout@v2 - -# - name: Download binaries -# uses: actions/download-artifact@v3 -# with: -# name: binaries -# path: artifacts - -# - name: TEMP LS -# run: ls -R 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: Set outputs -# id: vars -# run: | -# git config --global --add safe.directory '*' -# echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - -# - name: Build and push docker image -# uses: docker/build-push-action@v3 -# with: -# push: true -# tags: ghcr.io/${{ github.repository }}:preview--${{ steps.vars.outputs.sha_short }} -# platforms: linux/amd64 -# build-contexts: | -# artifacts=artifacts + build: + name: Build + runs-on: ubuntu-latest-4-cores + + steps: + - uses: actions/checkout@v4 + + - uses: Swatinem/rust-cache@v1 + + - uses: arduino/setup-protoc@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: "25.x" + + - name: Build binaries + run: | + cargo build -r --bin katana + cargo build -r --bin torii + cargo build -r --bin sozo + + - name: Archive binaries + id: artifacts + env: + VERSION_NAME: v${{ needs.prepare.outputs.tag_name }} + run: | + tar -czvf "dojo_${VERSION_NAME}_linux_amd64.tar.gz" -C ./target/release katana torii sozo + echo "file_name=dojo_${VERSION_NAME}_linux_amd64.tar.gz" >> $GITHUB_OUTPUT + shell: bash + + - name: Move Binaries + run: | + mkdir -p artifacts/linux/amd64/ + mv target/release/katana artifacts/linux/amd64/ + mv target/release/torii artifacts/linux/amd64/ + mv target/release/sozo artifacts/linux/amd64/ + shell: bash + + # Upload these for use with the Docker build later + - name: Upload docker binaries + uses: actions/upload-artifact@v3 + with: + name: binaries + path: artifacts + retention-days: 1 + + docker-build-and-push: + runs-on: ubuntu-latest + needs: [build] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Download binaries + uses: actions/download-artifact@v3 + with: + name: binaries + path: artifacts + + - name: TEMP LS + run: ls -R 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: Set outputs + id: vars + run: | + git config --global --add safe.directory '*' + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Build and push docker image + uses: docker/build-push-action@v3 + with: + push: true + tags: ghcr.io/${{ github.repository }}:preview--${{ steps.vars.outputs.sha_short }} + platforms: linux/amd64 + build-contexts: | + artifacts=artifacts deploy: runs-on: ubuntu-latest -# needs: [docker-build-and-push] + needs: [docker-build-and-push] steps: - name: Checkout repository uses: actions/checkout@v4 From 0dcec2c12cac2f754c0f17add9b311f297359450 Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 16:46:13 -0400 Subject: [PATCH 12/32] world input --- .github/workflows/preview.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index f165cb2948..a5feb28258 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -2,6 +2,12 @@ name: preview on: workflow_dispatch: + inputs: + world: + description: World address + required: false + type: string + default: '0x53b7efae79ce1d7729828bb6dee2cee09358fde4c4325805cf97678919a4855' push: branches: - ci-preview @@ -121,7 +127,7 @@ jobs: $XDG_CONFIG_HOME/.slot/bin/slot d create preview--${{ steps.vars.outputs.sha_short }} katana --version preview--${{ steps.vars.outputs.sha_short }} $XDG_CONFIG_HOME/.slot/bin/slot d create preview--${{ steps.vars.outputs.sha_short }} torii --version preview--${{ steps.vars.outputs.sha_short }} \ --rpc=http://slot.prod.svc.cluster.local/x/starknet/sepolia \ - --world=0x53b7efae79ce1d7729828bb6dee2cee09358fde4c4325805cf97678919a4855 \ + --world=${{ inputs.world }} --start-block=0 env: SLOT_AUTH: ${{ secrets.SLOT_AUTH }} From a18222b570ae1a81a6a775d0ea3a393a4e5e5eb6 Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 17:00:09 -0400 Subject: [PATCH 13/32] remove slot --- .github/workflows/preview.yml | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index a5feb28258..30dd70cd58 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -2,12 +2,6 @@ name: preview on: workflow_dispatch: - inputs: - world: - description: World address - required: false - type: string - default: '0x53b7efae79ce1d7729828bb6dee2cee09358fde4c4325805cf97678919a4855' push: branches: - ci-preview @@ -104,30 +98,3 @@ jobs: platforms: linux/amd64 build-contexts: | artifacts=artifacts - - deploy: - runs-on: ubuntu-latest - needs: [docker-build-and-push] - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set outputs - id: vars - run: | - git config --global --add safe.directory '*' - echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - - - name: Deploy on slot - run: | - set -eux - curl -L https://slot.cartridge.sh | bash - $XDG_CONFIG_HOME/.slot/bin/slotup - $XDG_CONFIG_HOME/.slot/bin/slot --version - $XDG_CONFIG_HOME/.slot/bin/slot d create preview--${{ steps.vars.outputs.sha_short }} katana --version preview--${{ steps.vars.outputs.sha_short }} - $XDG_CONFIG_HOME/.slot/bin/slot d create preview--${{ steps.vars.outputs.sha_short }} torii --version preview--${{ steps.vars.outputs.sha_short }} \ - --rpc=http://slot.prod.svc.cluster.local/x/starknet/sepolia \ - --world=${{ inputs.world }} - --start-block=0 - env: - SLOT_AUTH: ${{ secrets.SLOT_AUTH }} From 259fb63c666dd0e30bc153956ddb7f28846e583a Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 18:05:49 -0400 Subject: [PATCH 14/32] fix --- .github/workflows/preview.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 30dd70cd58..b46c360f65 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -32,15 +32,6 @@ jobs: cargo build -r --bin torii cargo build -r --bin sozo - - name: Archive binaries - id: artifacts - env: - VERSION_NAME: v${{ needs.prepare.outputs.tag_name }} - run: | - tar -czvf "dojo_${VERSION_NAME}_linux_amd64.tar.gz" -C ./target/release katana torii sozo - echo "file_name=dojo_${VERSION_NAME}_linux_amd64.tar.gz" >> $GITHUB_OUTPUT - shell: bash - - name: Move Binaries run: | mkdir -p artifacts/linux/amd64/ @@ -88,7 +79,7 @@ jobs: id: vars run: | git config --global --add safe.directory '*' - echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" - name: Build and push docker image uses: docker/build-push-action@v3 From ea45f9d5c371e13f245790c7f225caf410d653eb Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 18:07:06 -0400 Subject: [PATCH 15/32] bump --- .github/workflows/preview.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index b46c360f65..8d5818d083 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: Swatinem/rust-cache@v1 + - uses: Swatinem/rust-cache@v2 - uses: arduino/setup-protoc@v2 with: @@ -54,7 +54,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Download binaries uses: actions/download-artifact@v3 @@ -66,10 +66,10 @@ jobs: run: ls -R artifacts - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} From 053a4b586c59f7103d4d1613f07f32acc364333a Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 18:07:37 -0400 Subject: [PATCH 16/32] remove branch deploy --- .github/workflows/preview.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 8d5818d083..582a22ff13 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -2,9 +2,6 @@ name: preview on: workflow_dispatch: - push: - branches: - - ci-preview env: CARGO_TERM_COLOR: always From c781b159e91108f0f0ac9fab7b65201a75a39709 Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 22:23:23 -0400 Subject: [PATCH 17/32] dockerify all --- .dockerignore | 7 ++++ .github/Dockerfile | 45 ++++++++++++++++++++++ .github/workflows/preview.yml | 72 +++++++++-------------------------- Dockerfile | 5 +++ 4 files changed, 76 insertions(+), 53 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..93a8f1ce27 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +target/ +.git/ +.github/ +.idea/ +.vscode/ +.devcontainer/ +.cargo/ diff --git a/.github/Dockerfile b/.github/Dockerfile new file mode 100644 index 0000000000..dc80252e70 --- /dev/null +++ b/.github/Dockerfile @@ -0,0 +1,45 @@ +FROM rust:1.80.0-slim as chef + +# Install libclang and other necessary tools +RUN apt-get update && \ + apt-get install -y clang llvm-dev libclang-dev git libtool automake autoconf make curl + +RUN apt-get install -y protobuf-compiler + +# Verify and set LIBCLANG_PATH environment variable +RUN find /usr -name "libclang.so*" && \ + export LIBCLANG_PATH=$(find /usr -name "libclang.so*" | head -n 1 | xargs dirname) + +RUN rustup install 1.79.0 +RUN rustup component add cargo clippy rust-docs rust-std rustc rustfmt + +RUN cargo install cargo-chef + +FROM chef AS planner + +WORKDIR /app +COPY . . +RUN cargo chef prepare --recipe-path recipe.json + +FROM chef AS builder + +WORKDIR /app +COPY --from=planner /app/recipe.json recipe.json +# Build dependencies - this is the caching Docker layer! +RUN cargo chef cook --release --recipe-path recipe.json +RUN cargo build --release --bins + +# Build application +COPY . . +ENV PATH="/root/.cargo/bin:${PATH}" + +RUN cargo build --release --bins + +FROM rust:1-alpine + +WORKDIR / + +COPY --from=builder /app/target/release/katana /app/artifacts/ +COPY --from=builder /app/target/release/torii /app/artifacts/ +COPY --from=builder /app/target/release/sozo /app/artifacts/ +COPY --from=builder /app/target/release/saya /app/artifacts/ diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 582a22ff13..9db3080c33 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -3,68 +3,27 @@ name: preview on: workflow_dispatch: -env: - CARGO_TERM_COLOR: always - RUST_VERSION: 1.80.0 - REGISTRY_IMAGE: ghcr.io/${{ github.repository }} - jobs: - build: - name: Build - runs-on: ubuntu-latest-4-cores - - steps: - - uses: actions/checkout@v4 - - - uses: Swatinem/rust-cache@v2 - - - uses: arduino/setup-protoc@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - version: "25.x" - - - name: Build binaries - run: | - cargo build -r --bin katana - cargo build -r --bin torii - cargo build -r --bin sozo - - - name: Move Binaries - run: | - mkdir -p artifacts/linux/amd64/ - mv target/release/katana artifacts/linux/amd64/ - mv target/release/torii artifacts/linux/amd64/ - mv target/release/sozo artifacts/linux/amd64/ - shell: bash - - # Upload these for use with the Docker build later - - name: Upload docker binaries - uses: actions/upload-artifact@v3 - with: - name: binaries - path: artifacts - retention-days: 1 - - docker-build-and-push: + build-and-push: + name: Build and push runs-on: ubuntu-latest - needs: [build] steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Download binaries - uses: actions/download-artifact@v3 - with: - name: binaries - path: artifacts - - - name: TEMP LS - run: ls -R artifacts - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.ref_name }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-${{ github.ref_name }} + ${{ runner.os }}-buildx- + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: @@ -75,14 +34,21 @@ jobs: - name: Set outputs id: vars run: | - git config --global --add safe.directory '*' + git config --global --add safe.directory "${{ github.workspace }}" echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" + - name: Build binaries + run: | + docker build -t build -f .github/Dockerfile . + docker run --rm -v $(pwd)/artifacts:/artifacts build /bin/sh -c "cp -r /app/artifacts/* /artifacts" + - name: Build and push docker image uses: docker/build-push-action@v3 with: push: true tags: ghcr.io/${{ github.repository }}:preview--${{ steps.vars.outputs.sha_short }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new platforms: linux/amd64 build-contexts: | artifacts=artifacts diff --git a/Dockerfile b/Dockerfile index 261dac7ad2..cb52c92db0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,11 @@ RUN git clone https://github.com/Comcast/Infinite-File-Curtailer.git curtailer \ && make install \ && curtail --version +ENV TINI_VERSION v0.19.0 +ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini +RUN chmod +x /tini +ENTRYPOINT ["/tini", "--"] + FROM debian:bookworm-slim as base ARG TARGETPLATFORM From 4afe768973b7074c9a3469251cf94349d12982a7 Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 22:24:59 -0400 Subject: [PATCH 18/32] temp preview publish --- .github/workflows/preview.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 9db3080c33..126af25da1 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -2,6 +2,9 @@ name: preview on: workflow_dispatch: + push: + branches: + - ci-preview jobs: build-and-push: From 48c8e0a391339d11858e07351756280e72a31e96 Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 22:44:41 -0400 Subject: [PATCH 19/32] rust toolchain & fixes --- .dockerignore | 1 + .github/Dockerfile | 12 ++++++------ .github/workflows/preview.yml | 2 +- .gitignore | 2 ++ 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.dockerignore b/.dockerignore index 93a8f1ce27..2c7d1472f4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,3 +5,4 @@ target/ .vscode/ .devcontainer/ .cargo/ +artifacts/ diff --git a/.github/Dockerfile b/.github/Dockerfile index dc80252e70..802cdbf052 100644 --- a/.github/Dockerfile +++ b/.github/Dockerfile @@ -1,16 +1,16 @@ -FROM rust:1.80.0-slim as chef +FROM rust:slim as chef # Install libclang and other necessary tools RUN apt-get update && \ - apt-get install -y clang llvm-dev libclang-dev git libtool automake autoconf make curl - -RUN apt-get install -y protobuf-compiler + apt-get install -y clang llvm-dev libclang-dev git libtool automake autoconf make curl protobuf-compiler && \ + rm -rf /var/lib/apt/lists/* # Verify and set LIBCLANG_PATH environment variable RUN find /usr -name "libclang.so*" && \ export LIBCLANG_PATH=$(find /usr -name "libclang.so*" | head -n 1 | xargs dirname) -RUN rustup install 1.79.0 +COPY rust-toolchain.toml . +RUN rustup install $(cat rust-toolchain.toml | grep channel | cut -d' ' -f3 | tr -d '"') RUN rustup component add cargo clippy rust-docs rust-std rustc rustfmt RUN cargo install cargo-chef @@ -27,7 +27,7 @@ WORKDIR /app COPY --from=planner /app/recipe.json recipe.json # Build dependencies - this is the caching Docker layer! RUN cargo chef cook --release --recipe-path recipe.json -RUN cargo build --release --bins +RUN cargo build --release --bins # pre-cache some stuff # Build application COPY . . diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 126af25da1..38779f8c72 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -43,7 +43,7 @@ jobs: - name: Build binaries run: | docker build -t build -f .github/Dockerfile . - docker run --rm -v $(pwd)/artifacts:/artifacts build /bin/sh -c "cp -r /app/artifacts/* /artifacts" + docker run --rm -v "$(pwd)/artifacts:/artifacts" build /bin/sh -c "cp -r /app/artifacts/* /artifacts" - name: Build and push docker image uses: docker/build-push-action@v3 diff --git a/.gitignore b/.gitignore index cf16ca3022..75b10b8482 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ justfile spawn-and-move-db types-test-db examples/spawn-and-move/manifests/saya/** + +artifacts/ From d9c53d17bba3eb9d7fe9871a46e209e2d451c382 Mon Sep 17 00:00:00 2001 From: steebchen Date: Wed, 18 Sep 2024 22:50:58 -0400 Subject: [PATCH 20/32] docker wip --- .github/workflows/preview.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 38779f8c72..ac4e2ebdac 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -42,8 +42,10 @@ jobs: - name: Build binaries run: | - docker build -t build -f .github/Dockerfile . - docker run --rm -v "$(pwd)/artifacts:/artifacts" build /bin/sh -c "cp -r /app/artifacts/* /artifacts" + docker buildx build -t build -f .github/Dockerfile . \ + --cache-from type=local,src=/tmp/.buildx-cache \ + --cache-to type=local,dest=/tmp/.buildx-cache-new,mode=max + docker run --rm -v "$(pwd)/artifacts:/artifacts" build /bin/sh -c "cp -r /app/artifacts/* /artifacts" - name: Build and push docker image uses: docker/build-push-action@v3 @@ -51,7 +53,7 @@ jobs: push: true tags: ghcr.io/${{ github.repository }}:preview--${{ steps.vars.outputs.sha_short }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max platforms: linux/amd64 build-contexts: | artifacts=artifacts From 44e5efc286c569a9edb649dbfad90b8341104120 Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 19 Sep 2024 11:28:44 -0400 Subject: [PATCH 21/32] build local and run --- .github/workflows/preview.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index ac4e2ebdac..4267690761 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -40,12 +40,21 @@ jobs: git config --global --add safe.directory "${{ github.workspace }}" echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" - - name: Build binaries + - name: Build Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: .github/Dockerfile + load: true + tags: build-local:latest + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + platforms: linux/amd64 + + - name: Build local binaries run: | - docker buildx build -t build -f .github/Dockerfile . \ - --cache-from type=local,src=/tmp/.buildx-cache \ - --cache-to type=local,dest=/tmp/.buildx-cache-new,mode=max - docker run --rm -v "$(pwd)/artifacts:/artifacts" build /bin/sh -c "cp -r /app/artifacts/* /artifacts" + set -eux + docker run --rm -v "$(pwd)/artifacts:/artifacts" build-local:latest /bin/sh -c "cp -r /app/artifacts/* /artifacts" - name: Build and push docker image uses: docker/build-push-action@v3 From 64d19a18f6464d6107bac5a535bf83250f2b9a7c Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 19 Sep 2024 12:00:52 -0400 Subject: [PATCH 22/32] revert --- Dockerfile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index cb52c92db0..261dac7ad2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,11 +14,6 @@ RUN git clone https://github.com/Comcast/Infinite-File-Curtailer.git curtailer \ && make install \ && curtail --version -ENV TINI_VERSION v0.19.0 -ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini -RUN chmod +x /tini -ENTRYPOINT ["/tini", "--"] - FROM debian:bookworm-slim as base ARG TARGETPLATFORM From c91600f7039768264d8f527708feeac9b9e7e9ec Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 19 Sep 2024 12:01:18 -0400 Subject: [PATCH 23/32] checkout fix --- .github/workflows/preview.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 4267690761..df752fec30 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -12,9 +12,6 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -27,6 +24,9 @@ jobs: ${{ runner.os }}-buildx-${{ github.ref_name }} ${{ runner.os }}-buildx- + - name: Checkout repository + uses: actions/checkout@v4 + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: From 3198ed2c98df668de81d459e567e9cc6422c79d6 Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 19 Sep 2024 12:01:47 -0400 Subject: [PATCH 24/32] ls --- .github/workflows/preview.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index df752fec30..fffef8d0fd 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -55,6 +55,7 @@ jobs: run: | set -eux docker run --rm -v "$(pwd)/artifacts:/artifacts" build-local:latest /bin/sh -c "cp -r /app/artifacts/* /artifacts" + ls -R artifacts/ - name: Build and push docker image uses: docker/build-push-action@v3 From 87d2b3ef8c402cb8c5f1b91b5a2468411154f7ed Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 19 Sep 2024 12:56:20 -0400 Subject: [PATCH 25/32] fix --- .github/workflows/preview.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index fffef8d0fd..4468967d8b 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -54,8 +54,10 @@ jobs: - name: Build local binaries run: | set -eux - docker run --rm -v "$(pwd)/artifacts:/artifacts" build-local:latest /bin/sh -c "cp -r /app/artifacts/* /artifacts" + docker run --rm -v "$(pwd)/artifacts:/artifacts" build-local:latest /bin/sh -c "cp -r /app/artifacts/* /artifacts/$PLATFORM" ls -R artifacts/ + env: + PLATFORM: linux/amd64 - name: Build and push docker image uses: docker/build-push-action@v3 From ec35a9d3985e4070427602ad28ab125d6abf169f Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 19 Sep 2024 13:26:14 -0400 Subject: [PATCH 26/32] fix --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 4468967d8b..8f0958f25f 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -54,7 +54,7 @@ jobs: - name: Build local binaries run: | set -eux - docker run --rm -v "$(pwd)/artifacts:/artifacts" build-local:latest /bin/sh -c "cp -r /app/artifacts/* /artifacts/$PLATFORM" + docker run --rm -v "$(pwd)/artifacts:/artifacts/artifacts/$PLATFORM" build-local:latest /bin/sh -c "cp -r /app/artifacts/* /artifacts/$PLATFORM" ls -R artifacts/ env: PLATFORM: linux/amd64 From 3f8d57b67e98c4e9cd265b40dec23429a3ebc6f1 Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 19 Sep 2024 14:17:12 -0400 Subject: [PATCH 27/32] fix artifacts --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 8f0958f25f..e547b26a67 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -54,7 +54,7 @@ jobs: - name: Build local binaries run: | set -eux - docker run --rm -v "$(pwd)/artifacts:/artifacts/artifacts/$PLATFORM" build-local:latest /bin/sh -c "cp -r /app/artifacts/* /artifacts/$PLATFORM" + docker run --rm -v "$(pwd)/artifacts/$PLATFORM:/artifacts" build-local:latest /bin/sh -c "cp -r /app/artifacts/* /artifacts/" ls -R artifacts/ env: PLATFORM: linux/amd64 From cb80ecc4a2c4a990b13047564498dd68ea81c487 Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 19 Sep 2024 15:09:04 -0400 Subject: [PATCH 28/32] move cache --- .github/workflows/preview.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index e547b26a67..55e9fe7cda 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -69,3 +69,11 @@ jobs: platforms: linux/amd64 build-contexts: | artifacts=artifacts + + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache From cf7cc6276ce36b176c4ef78c441e3bc4a57f0c30 Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 19 Sep 2024 15:54:57 -0400 Subject: [PATCH 29/32] separate cache --- .github/workflows/preview.yml | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 55e9fe7cda..8939198ae5 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -7,8 +7,7 @@ on: - ci-preview jobs: - build-and-push: - name: Build and push + publish: runs-on: ubuntu-latest steps: @@ -18,7 +17,16 @@ jobs: - name: Cache Docker layers uses: actions/cache@v4 with: - path: /tmp/.buildx-cache + path: /tmp/.buildx-cache/prebuild + key: ${{ runner.os }}-buildx-${{ github.ref_name }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-${{ github.ref_name }} + ${{ runner.os }}-buildx- + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache/build key: ${{ runner.os }}-buildx-${{ github.ref_name }}-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx-${{ github.ref_name }} @@ -47,8 +55,8 @@ jobs: file: .github/Dockerfile load: true tags: build-local:latest - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + cache-from: type=local,src=/tmp/.buildx-cache/prebuild + cache-to: type=local,dest=/tmp/.buildx-cache-new/prebuild,mode=max platforms: linux/amd64 - name: Build local binaries @@ -64,8 +72,8 @@ jobs: with: push: true tags: ghcr.io/${{ github.repository }}:preview--${{ steps.vars.outputs.sha_short }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + cache-from: type=local,src=/tmp/.buildx-cache/build + cache-to: type=local,dest=/tmp/.buildx-cache-new/build,mode=max platforms: linux/amd64 build-contexts: | artifacts=artifacts @@ -75,5 +83,7 @@ jobs: # https://github.com/moby/buildkit/issues/1896 name: Move cache run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache + rm -rf /tmp/.buildx-cache/prebuild + mv /tmp/.buildx-cache-new/prebuild /tmp/.buildx-cache/prebuild + rm -rf /tmp/.buildx-cache/build + mv /tmp/.buildx-cache-new/build /tmp/.buildx-cache/build From 55819aa0b66b633ea58f5d0c0a7cd189917ed3e9 Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 19 Sep 2024 14:58:03 -0400 Subject: [PATCH 30/32] minor adaptions --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 8939198ae5..d2cbe701bc 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -45,6 +45,7 @@ jobs: - name: Set outputs id: vars run: | + set -eux git config --global --add safe.directory "${{ github.workspace }}" echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" @@ -63,7 +64,6 @@ jobs: run: | set -eux docker run --rm -v "$(pwd)/artifacts/$PLATFORM:/artifacts" build-local:latest /bin/sh -c "cp -r /app/artifacts/* /artifacts/" - ls -R artifacts/ env: PLATFORM: linux/amd64 From ba0273b521b4870683f67dc9182b6f2c4cef21e4 Mon Sep 17 00:00:00 2001 From: steebchen Date: Thu, 19 Sep 2024 16:40:36 -0400 Subject: [PATCH 31/32] bump to 32 cores yolo --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index d2cbe701bc..302a9e3d20 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -8,7 +8,7 @@ on: jobs: publish: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-32-cores steps: - name: Set up Docker Buildx From a09b21bdb285ad7d9b9bc4a2deb5e6a7e308dcbd Mon Sep 17 00:00:00 2001 From: steebchen Date: Fri, 20 Sep 2024 12:20:27 -0400 Subject: [PATCH 32/32] remove temp push trigger --- .github/workflows/preview.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 302a9e3d20..fc1d296883 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -2,9 +2,6 @@ name: preview on: workflow_dispatch: - push: - branches: - - ci-preview jobs: publish: