From 7bb1d771098bff12e912795724aaee1a62d24f4f Mon Sep 17 00:00:00 2001 From: Mathew Richmond Date: Thu, 10 Oct 2024 16:59:37 -0600 Subject: [PATCH] Different CI methodology --- .github/workflows/.DS_Store | Bin 0 -> 6148 bytes .github/workflows/build.yml | 102 ++++++++++++++++++++++++++- .github/workflows/docker-publish.yml | 4 -- Simple.Dockerfile | 18 +++++ 4 files changed, 118 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/.DS_Store create mode 100644 Simple.Dockerfile diff --git a/.github/workflows/.DS_Store b/.github/workflows/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0/ + IMAGE_NAME: ${{ github.repository }} + concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -31,4 +36,97 @@ jobs: run: cargo test - name: Build - run: cargo build + run: cargo build --release + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: x86_64-unknown-linux-gnu + path: | + target/release/cached-eth-rpc + + build-arm: + runs-on: buildjet-4vcpu-ubuntu-2204-arm + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Enable Rust Caching + uses: Swatinem/rust-cache@v2 + with: + prefix-key: "arm" + + - name: Test + run: cargo test + + - name: Build + run: cargo build --release + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: aarch64-unknown-linux-gnu + path: | + target/release/cached-eth-rpc + + build-dockers: + runs-on: ubuntu-latest + needs: [build, build-arm] + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Download executables AMD + uses: actions/download-artifact@v4 + with: + name: x86_64-unknown-linux-gnu + path: target/amd64/release + + - name: Download executables ARM + uses: actions/download-artifact@v4 + with: + name: aarch64-unknown-linux-gnu + path: target/arm64/release + + - name: Setup Docker BuildKit (buildx) + uses: docker/setup-buildx-action@v3 + + - name: Login to Github Container Repo + uses: docker/login-action@v3 + if: github.event_name != 'pull_request' + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Generate docker metadata + uses: docker/metadata-action@v5 + id: cached_eth_rpc + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push docker + uses: docker/build-push-action@v6 + with: + context: ./ + file: ./Simple.Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.cached_eth_rpc.outputs.tags }} + labels: ${{ steps.cached_eth_rpc.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + + + + + + + + + + + diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7f1eec3..eb98c9c 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -6,10 +6,6 @@ name: Docker # documentation. on: - push: - branches: - - "main" - pull_request: workflow_dispatch: concurrency: diff --git a/Simple.Dockerfile b/Simple.Dockerfile new file mode 100644 index 0000000..51488b4 --- /dev/null +++ b/Simple.Dockerfile @@ -0,0 +1,18 @@ +FROM ubuntu:jammy + +ARG TARGETARCH + +RUN apt-get update \ + && apt-get install -y ca-certificates curl libcurl4 openssl wait-for-it tini \ + && rm -rf /var/lib/apt/lists/* +RUN update-ca-certificates + +COPY target/$TARGETARCH/release/cached-eth-rpc /app/cached-eth-rpc +RUN chmod +x /bin/cdn-broker + +ENV ENDPOINTS="eth-chain=https://rpc.ankr.com/eth,bsc-chain=https://rpc.ankr.com/bsc" +ENV RUST_LOG="debug" +ENV RUST_LOG_FORMAT="full" +HEALTHCHECK --interval=1s --timeout=1s --retries=1 CMD curl http://localhost:8124 +EXPOSE 8124 +ENTRYPOINT ["tini", "--", "/app/cached-eth-rpc" ]