Skip to content

Commit

Permalink
Different CI methodology
Browse files Browse the repository at this point in the history
  • Loading branch information
Ancient123 committed Oct 10, 2024
1 parent 38c4e3e commit 7bb1d77
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 6 deletions.
Binary file added .github/workflows/.DS_Store
Binary file not shown.
102 changes: 100 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ name: Build
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -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












4 changes: 0 additions & 4 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ name: Docker
# documentation.

on:
push:
branches:
- "main"
pull_request:
workflow_dispatch:

concurrency:
Expand Down
18 changes: 18 additions & 0 deletions Simple.Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]

0 comments on commit 7bb1d77

Please sign in to comment.