From e9d6e1e001fa737e9263409df27abc1c45e5c4b6 Mon Sep 17 00:00:00 2001 From: YangKeao Date: Thu, 19 May 2022 15:42:23 +0800 Subject: [PATCH] migrate to native arm build machine Signed-off-by: YangKeao --- .github/workflows/release.yml | 32 +++++++++++++++---------- Dockerfile | 45 ----------------------------------- 2 files changed, 19 insertions(+), 58 deletions(-) delete mode 100644 Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 78e07fe..6ea04dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,23 +25,30 @@ jobs: build: name: Upload Release needs: create_release - runs-on: ubuntu-latest strategy: matrix: - include: - - target: aarch64-unknown-linux-gnu - cc: gcc-aarch64-linux-gnu - - target: x86_64-unknown-linux-gnu - cc: gcc + arch: [x86_64, aarch64] + runs-on: ${{ fromJson('{"x86_64":"ubuntu-latest", "aarch64":["self-hosted", "Linux", "ARM64"]}')[matrix.arch] }} + container: docker.io/debian:buster-slim steps: - name: Checkout code uses: actions/checkout@v2 + + - name: Install curl + run: | + apt-get update -y + apt-get install build-essential gcc curl git pkg-config -y + + - name: Install latest nightly + uses: actions-rs/toolchain@v1 + - name: Build run: | - DOCKER_BUILDKIT=1 docker build --build-arg CC=${{ matrix.cc }} --build-arg TARGET=${{ matrix.target }} --build-arg HTTP_PROXY=${HTTP_PROXY} --build-arg HTTPS_PROXY=${HTTPS_PROXY} . -t chaos-mesh/nsexec - docker run -v ${PWD}:/opt/mount:z --rm --entrypoint cp chaos-mesh/nsexec /nsexec /opt/mount/nsexec - docker run -v ${PWD}:/opt/mount:z --rm --entrypoint cp chaos-mesh/nsexec /libnsenter.so /opt/mount/libnsenter.so - tar -czvf ./nsexec-${{ matrix.target }}.tar.gz ./libnsenter.so ./nsexec + cargo build --release --all + cp target/$TARGET/release/nsexec ./nsexec + cp target/$TARGET/release/libnsenter.so ./libnsenter.so + tar -czvf ./nsexec-${{ matrix.arch }}-unknown-linux-gnu.tar.gz ./libnsenter.so ./nsexec + - name: Upload Release Asset id: upload-release-asset uses: actions/upload-release-asset@v1 @@ -49,7 +56,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.create_release.outputs.upload_url }} - asset_path: ./nsexec-${{ matrix.target }}.tar.gz - asset_name: nsexec-${{ matrix.target }}.tar.gz + asset_path: ./nsexec-${{ matrix.arch }}-unknown-linux-gnu.tar.gz + asset_name: nsexec-${{ matrix.arch }}-unknown-linux-gnu.tar.gz asset_content_type: application/zip - diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 6ec6a69..0000000 --- a/Dockerfile +++ /dev/null @@ -1,45 +0,0 @@ -# syntax=docker/dockerfile:experimental - -FROM debian:buster-slim - -ENV DEBIAN_FRONTEND noninteractive - -ARG HTTPS_PROXY -ARG HTTP_PROXY -ARG TARGET=x86_64-unknown-linux-gnu -ARG CC=gcc - -ENV http_proxy $HTTP_PROXY -ENV https_proxy $HTTPS_PROXY - -RUN apt-get update && apt-get install build-essential $CC curl git pkg-config -y && rm -rf /var/lib/apt/lists/* - -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain nightly-2021-12-23 -y -ENV PATH "/root/.cargo/bin:${PATH}" - -RUN rustup target add $TARGET - -RUN if [ -n "$HTTP_PROXY" ]; then echo "[http]\n\ -proxy = \"${HTTP_PROXY}\"\n\ -"\ ->> /root/.cargo/config ; fi - -RUN echo "[target.aarch64-unknown-linux-gnu]\n\ -linker = \"aarch64-linux-gnu-gcc\"\n\ -"\ ->> /root/.cargo/config - -COPY . /nsexec-build - -WORKDIR /nsexec-build - -ENV RUSTFLAGS "-Z relro-level=full" -RUN --mount=type=cache,target=/nsexec-build/target \ - --mount=type=cache,target=/root/.cargo/registry \ - cargo build --release --all --target $TARGET - -RUN --mount=type=cache,target=/nsexec-build/target \ - cp /nsexec-build/target/$TARGET/release/nsexec /nsexec - -RUN --mount=type=cache,target=/nsexec-build/target \ - cp /nsexec-build/target/$TARGET/release/libnsenter.so /libnsenter.so \ No newline at end of file