From 45818096a5af31c34546b70da5f5b7ac982d0ca6 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 6 Oct 2023 02:03:18 +0200 Subject: [PATCH] Build ARM64 client on dedicated runner (#376) --- .github/workflows/linux-build.yml | 46 ++++++++++++++++++++++--------- crates/cli/Dockerfile | 46 ------------------------------- 2 files changed, 33 insertions(+), 59 deletions(-) delete mode 100644 crates/cli/Dockerfile diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index a124c149936..b9b92962dfe 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -8,31 +8,51 @@ on: - master jobs: - linux-client: + linux-amd64-client: runs-on: bare-metal steps: - name: Checkout uses: actions/checkout@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Compile Aarch64 Docker + - name: Compile x86 run: | - docker buildx build --platform=linux/arm64 -f crates/cli/Dockerfile -t cli . + export PATH=$HOME/.cargo/bin:$PATH + cargo build --release -p spacetimedb-cli mkdir build - id=$(docker create cli) - docker cp $id:/usr/local/bin/spacetime - > build/spacetime.linux-arm64.tar - docker rm -v $id - cd build - gzip spacetime.linux-arm64.tar + mv target/release/spacetime build/spacetime + cd build && tar -czf spacetime.linux-amd64.tar.gz spacetime + rm spacetime - - name: Compile x86 + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + - name: Upload to DO Spaces + uses: shallwefootball/s3-upload-action@master + with: + aws_key_id: ${{ secrets.AWS_KEY_ID }} + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}} + aws_bucket: ${{ vars.AWS_BUCKET }} + source_dir: build + endpoint: https://nyc3.digitaloceanspaces.com + destination_dir: ${{ steps.extract_branch.outputs.branch }} + + linux-arm64-client: + runs-on: arm-runner + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Compile ARM64 run: | + export PATH=$HOME/.cargo/bin:$PATH cargo build --release -p spacetimedb-cli + mkdir build mv target/release/spacetime build/spacetime - cd build && tar -czf spacetime.linux-amd64.tar.gz spacetime + cd build && tar -czf spacetime.linux-arm64.tar.gz spacetime rm spacetime - name: Extract branch name diff --git a/crates/cli/Dockerfile b/crates/cli/Dockerfile deleted file mode 100644 index a538d0efd9c..00000000000 --- a/crates/cli/Dockerfile +++ /dev/null @@ -1,46 +0,0 @@ -ARG CARGO_PROFILE=release - -FROM rust:1.72.0 AS chef -RUN rust_target=$(rustc -vV | awk '/^host:/{ print $2 }') && \ - curl https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-$rust_target.tgz -fL | tar xz -C $CARGO_HOME/bin -RUN cargo binstall -y cargo-chef@0.1.56 -WORKDIR /usr/src/app - -FROM chef AS planner -COPY . . -RUN cargo chef prepare --recipe-path recipe.json - -FROM chef AS builder - -RUN apt-get update && apt-get install -y protobuf-compiler - -RUN cargo binstall -y cargo-watch@8.4.0 -RUN cargo binstall -y flamegraph@0.6.2 - -COPY --from=planner /usr/src/app/recipe.json . - -ENV CARGO_INCREMENTAL=0 - -ARG CARGO_PROFILE=release - -RUN cargo chef cook -p spacetimedb-cli --profile=${CARGO_PROFILE} - -COPY . . -RUN cargo build -p spacetimedb-cli --profile=${CARGO_PROFILE} --locked - -FROM builder as env-dev -ENV SPACETIMEDB_LOG_CONFIG=/usr/src/app/crates/standalone/log.conf -ENV SPACETIMEDB_JWT_PUB_KEY=/etc/spacetimedb/id_ecdsa.pub -ENV SPACETIMEDB_JWT_PRIV_KEY=/etc/spacetimedb/id_ecdsa -ENV PATH="/usr/src/app/target/debug:${PATH}" - -FROM debian as env-release -COPY --from=builder /usr/src/app/target/release/spacetime /usr/local/bin/ -COPY --from=builder /usr/src/app/crates/standalone/log.conf /etc/spacetimedb/ - -FROM env-${CARGO_PROFILE} - -EXPOSE 3000 - -ENV RUST_BACKTRACE=1 -ENTRYPOINT ["spacetimedb"]