From 153ce5dbad0212aecb60d5b2e30faa5a9eea2ed9 Mon Sep 17 00:00:00 2001 From: Eshanchik Date: Wed, 11 Sep 2024 18:21:00 +0300 Subject: [PATCH] add build and container event-indexer --- .github/workflows/build_and_push.yaml | 28 ++++++++++++++ Dockerfile_indexer | 54 +++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 Dockerfile_indexer diff --git a/.github/workflows/build_and_push.yaml b/.github/workflows/build_and_push.yaml index e20415e..c9baa0b 100644 --- a/.github/workflows/build_and_push.yaml +++ b/.github/workflows/build_and_push.yaml @@ -94,3 +94,31 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + build_and_publish_indexer: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v3 + id: meta + with: + images: ghcr.io/ambrosus/airdao-event-indexer + + - name: Build and push + uses: docker/build-push-action@v2 + with: + file: Dockerfile_indexer + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile_indexer b/Dockerfile_indexer new file mode 100644 index 0000000..51c1804 --- /dev/null +++ b/Dockerfile_indexer @@ -0,0 +1,54 @@ +FROM debian:bullseye-slim AS builder +WORKDIR /tmp/builder + +COPY . . + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH \ + RUST_VERSION=1.80 + +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + ca-certificates \ + gcc \ + libc6-dev \ + wget \ + ; \ + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='bb31eaf643926b2ee9f4d8d6fc0e2835e03c0a60f34d324048aa194f0b29a71c' ;; \ + armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='6626b90205d7fe7058754c8e993b7efd91dedc6833a11a225b296b7c2941194f' ;; \ + arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='4ccaa7de6b8be1569f6b764acc28e84f5eca342f5162cd5c810891bff7ed7f74' ;; \ + i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='34392b53a25c56435b411d3e575b63aab962034dd1409ba405e708610c829607' ;; \ + *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ + esac; \ + url="https://static.rust-lang.org/rustup/archive/1.25.2/${rustArch}/rustup-init"; \ + wget "$url"; \ + echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ + chmod +x rustup-init; \ + ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ + rm rustup-init; \ + chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ + rustup --version; \ + cargo --version; \ + rustc --version; \ + apt-get remove -y --auto-remove \ + wget \ + ; \ + rm -rf /var/lib/apt/lists/*; +RUN apt-get update && apt-get install -y lsb-release ca-certificates libssl-dev pkg-config && \ + rustup component add rustfmt clippy && \ + cargo build --release + + +FROM debian:bullseye-slim +WORKDIR /app + +COPY --from=builder /tmp/builder/target/release/airdao-event-indexer . +COPY --from=builder /tmp/builder/event-indexer /app/event-indexer + +RUN apt-get update && apt-get install -y lsb-release ca-certificates libssl-dev && apt-get clean all + +CMD ["./airdao-event-indexer"]