From 98ebb3509f4fd0eb1d17601b635ad16157b6bb24 Mon Sep 17 00:00:00 2001 From: Kasper Ziemianek Date: Wed, 15 May 2024 13:52:52 +0200 Subject: [PATCH] build bitacross hw worker docker image --- .github/workflows/build_bitacross.yml | 59 +++++++++++++++++++++++++++ bitacross-worker/build.Dockerfile | 18 +++++--- 2 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build_bitacross.yml diff --git a/.github/workflows/build_bitacross.yml b/.github/workflows/build_bitacross.yml new file mode 100644 index 0000000000..012e497a69 --- /dev/null +++ b/.github/workflows/build_bitacross.yml @@ -0,0 +1,59 @@ +name: Build bitacross-worker + +on: push + +env: + CARGO_TERM_COLOR: always + DOCKER_BUILDKIT: 1 + +jobs: + build-worker: + runs-on: tee-prod-builder + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Build local builder + uses: docker/build-push-action@v5 + with: + context: . + file: bitacross-worker/build.Dockerfile + tags: local-builder:latest + target: builder + build-args: | + WORKER_MODE_ARG=offchain-worker + SGX_MODE=HW + ADDITIONAL_FEATURES_ARG= + IMAGE_FOR_RELEASE=true + + - name: Build worker + uses: docker/build-push-action@v5 + with: + context: . + file: bitacross-worker/build.Dockerfile + tags: litentry/bitacross-worker:latest + target: deployed-worker + + - name: Build cli + uses: docker/build-push-action@v5 + with: + context: . + file: bitacross-worker/build.Dockerfile + tags: litentry/bitacross-cli:latest + target: deployed-client + + - name: Save docker images + run: docker save litentry/bitacross-worker:latest litentry/bitacross-cli:latest | gzip > bitacross-worker.tar.gz + + - name: Upload docker images + uses: actions/upload-artifact@v4 + with: + name: bitacross-worker + path: bitacross-worker.tar.gz + if-no-files-found: error + + - name: Fail early + if: failure() + uses: andymckay/cancel-action@0.4 diff --git a/bitacross-worker/build.Dockerfile b/bitacross-worker/build.Dockerfile index f417478865..8d057c2633 100644 --- a/bitacross-worker/build.Dockerfile +++ b/bitacross-worker/build.Dockerfile @@ -48,17 +48,25 @@ ENV WORKER_MODE=$WORKER_MODE_ARG ARG ADDITIONAL_FEATURES_ARG ENV ADDITIONAL_FEATURES=$ADDITIONAL_FEATURES_ARG +ARG IMAGE_FOR_RELEASE=false +ENV IMAGE_FOR_RELEASE=$IMAGE_FOR_RELEASE + ARG FINGERPRINT=none WORKDIR $HOME/bitacross-worker COPY . $HOME RUN \ - rm -rf /opt/rust/registry/cache && mv /home/ubuntu/worker-cache/registry/cache /opt/rust/registry && \ - rm -rf /opt/rust/registry/index && mv /home/ubuntu/worker-cache/registry/index /opt/rust/registry && \ - rm -rf /opt/rust/git/db && mv /home/ubuntu/worker-cache/git/db /opt/rust/git && \ - rm -rf /opt/rust/sccache && mv /home/ubuntu/worker-cache/sccache /opt/rust && \ - make && sccache --show-stats + if [ "$IMAGE_FOR_RELEASE" = "true" ]; then \ + echo "Omit cache for release image"; \ + make; \ + else \ + rm -rf /opt/rust/registry/cache && mv /home/ubuntu/worker-cache/registry/cache /opt/rust/registry && \ + rm -rf /opt/rust/registry/index && mv /home/ubuntu/worker-cache/registry/index /opt/rust/registry && \ + rm -rf /opt/rust/git/db && mv /home/ubuntu/worker-cache/git/db /opt/rust/git && \ + rm -rf /opt/rust/sccache && mv /home/ubuntu/worker-cache/sccache /opt/rust && \ + make && sccache --show-stats; \ + fi RUN cargo test --release