Skip to content

Commit

Permalink
feat: indexer dockerfile for karnot (#1018)
Browse files Browse the repository at this point in the history
* feat: indexer dockerfile for karnot

* fix sha

* test release workflow

* fix test

* revert testing

* answer comments

---------

Co-authored-by: Gregory Edison <gregory.edison1993@gmail.com>
  • Loading branch information
Eikix and greged93 authored May 6, 2024
1 parent 4271ee5 commit 0708758
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: RPC
name: release

on:
release:
Expand All @@ -8,6 +8,7 @@ on:
env:
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}/node
DOCKER_USERNAME: ${{ github.actor }}
INDEXER_IMAGE: ghcr.io/${{ github.repository }}/indexer

jobs:
prepare:
Expand Down Expand Up @@ -118,3 +119,36 @@ jobs:
--tag ${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }} \
--tag ${{ env.REGISTRY_IMAGE }}:latest \
--push
build-push-indexer-docker:
runs-on: ubuntu-latest-16-cores
strategy:
matrix:
include:
- platform: linux/amd64
apibara_sink_bin_dir: sci7y4a8r7yz05094pl88h3d7vv1s98f
- platform: linux/arm64
apibara_sink_bin_dir: 5p0wgpyfsk19v8rrprnykiv5inzx8zag
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ env.INDEXER_IMAGE }}:${{ github.ref_name }}, ${{ env.INDEXER_IMAGE }}:latest
context: .
file: ./docker/indexer/Dockerfile
platforms: ${{ matrix.platform }}
build-args: |
APIBARA_SINK_BIN_DIR=${{ matrix.apibara_sink_bin_dir }}
1 change: 1 addition & 0 deletions .github/workflows/spell_check.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Spell Check

on:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: test

on:
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,11 @@ the passing tests:
If you which to run our hive test suite locally, the following steps should be taken:

- Set up the repo: `make setup`.
- Build a local docker image of the RPC:
- Build a local docker image of the RPC. Check the hive [Dockerfile](docker/hive/Dockerfile)
for the values for `xxx` and `yyy`:

```shell
docker build --build-arg APIBARA_STARKNET_BIN_DIR=f7va4mjqww1kkpp4il6y295dgcwq147v --build-arg APIBARA_SINK_BIN_DIR=5p0wgpyfsk19v8rrprnykiv5inzx8zag -t hive . -f docker/hive/Dockerfile
docker build --build-arg APIBARA_STARKNET_BIN_DIR=xxx --build-arg APIBARA_SINK_BIN_DIR=yyy -t hive . -f docker/hive/Dockerfile
```

- Checkout the Kakarot fork of hive: `git clone https://github.com/kkrt-labs/hive`
Expand Down Expand Up @@ -462,3 +463,5 @@ Thanks goes to these wonderful people
This project follows the
[all-contributors](https://github.com/all-contributors/all-contributors)
specification. Contributions of any kind welcome!


7 changes: 4 additions & 3 deletions docker/hive/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ FROM ghcr.io/dojoengine/dojo:v0.6.0-alpha.6 as katana
FROM quay.io/apibara/starknet:1.4.1 as apibara
FROM quay.io/apibara/sink-mongo:0.7.0 as indexer
FROM debian:bookworm as apibara-build
RUN apt-get update && apt-get install -y patchelf && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install --no-install-recommends -y patchelf && rm -rf /var/lib/apt/lists/*

# Apibara Starknet and Sink are built with Nix, so we need to extract the binaries from the Nix store
# ⚠️ When modifying the tag of Apibara, make sure to change the Github CI workflow, and Indexer dockerfile as well
# Depending on the platform, the path to the binaries will be different
# These values need to be updated if the version of ApiBara Starknet or Sink change.
# platform: linux/amd64:
Expand Down Expand Up @@ -62,7 +63,7 @@ RUN curl -L https://foundry.paradigm.xyz -o foundry.sh \
&& chmod +x foundry.sh \
&& ./foundry.sh \
&& foundryup \
&& apt-get update && apt-get install -y \
&& apt-get update && apt-get install --no-install-recommends -y \
jq \
wget \
docker.io \
Expand Down Expand Up @@ -119,7 +120,7 @@ RUN cargo build \

FROM debian:bookworm-slim as base
# Install any necessary dependencies
RUN apt-get update && apt-get install -y tini curl jq libssl-dev ca-certificates && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install --no-install-recommends -y tini curl jq libssl-dev ca-certificates && rm -rf /var/lib/apt/lists/*

# Environment
#############
Expand Down
30 changes: 30 additions & 0 deletions docker/indexer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM quay.io/apibara/sink-mongo:0.7.0 as indexer

FROM debian:latest as apibara-build
RUN apt-get update && apt-get install --no-install-recommends -y patchelf && rm -rf /var/lib/apt/lists/*

ARG BUILDPLATFORM
ARG APIBARA_SINK_BIN_DIR

COPY --from=indexer /nix/store/${APIBARA_SINK_BIN_DIR}-apibara-sink-mongo-0.7.0/bin/apibara-sink-mongo /usr/local/bin/sink-mongo

RUN case $BUILDPLATFORM in \
"linux/amd64") \
patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 /usr/local/bin/sink-mongo; \
;; \
"linux/arm64") \
patchelf --set-interpreter /lib/ld-linux-aarch64.so.1 /usr/local/bin/sink-mongo; \
;; \
*) \
echo "Unknown BUILDPLATFORM: $BUILDPLATFORM"; \
exit 1; \
;; \
esac


FROM debian:latest

COPY ./indexer /usr/src/app/code
COPY --from=apibara-build /usr/local/bin/sink-mongo /usr/local/bin/sink-mongo

CMD ["sink-mongo", "run", "/usr/src/app/code/src/main.ts"]
4 changes: 2 additions & 2 deletions docker/rpc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ COPY . .
# Install system dependencies
RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y libclang-dev
apt-get install --no-install-recommends -y libclang-dev
RUN cargo build --release --bin kakarot-rpc

FROM debian:bookworm-slim AS runtime
Expand All @@ -38,7 +38,7 @@ HEALTHCHECK --interval=3s --timeout=5s --start-period=1s --retries=5 \

RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y libssl-dev ca-certificates tini curl && \
apt-get install --no-install-recommends -y libssl-dev ca-certificates tini curl && \
rm -rf /var/lib/apt/lists/*

# Copy the indexer code into the RPC
Expand Down
4 changes: 2 additions & 2 deletions docker/rpc/Dockerfile.cross
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG TARGETARCH
# Install any necessary dependencies
RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y libssl-dev ca-certificates tini curl && \
apt-get install --no-install-recommends -y libssl-dev ca-certificates tini curl && \
rm -rf /var/lib/apt/lists/*

# Copy the built binary. This assumes that the binary
Expand All @@ -29,7 +29,7 @@ HEALTHCHECK --interval=3s --timeout=5s --start-period=1s --retries=5 \

RUN apt-get update && \
apt-get -y upgrade && \
apt-get install -y libssl-dev ca-certificates tini curl && \
apt-get install --no-install-recommends -y libssl-dev ca-certificates tini curl && \
rm -rf /var/lib/apt/lists/*

# Copy the indexer code into the RPC
Expand Down

0 comments on commit 0708758

Please sign in to comment.