diff --git a/.github/actions/docker-publish/action.yaml b/.github/actions/docker-publish/action.yaml new file mode 100644 index 0000000..a51a536 --- /dev/null +++ b/.github/actions/docker-publish/action.yaml @@ -0,0 +1,86 @@ +name: 'Build & Plush Docker' + +inputs: + compose-version: + description: 'Docker Compose version' + default: 2.6.0 + registry: + description: 'Docker registry service' + default: ghcr.io + username: + description: 'Username for https://ghcr.io' + required: true + password: + description: 'Password for https://ghcr.io' + required: true + image: + description: 'Image name with provider url' + required: true + dockerfile: + description: 'Path to the Dockerfile' + required: true + context: + description: 'Path to the Context' + default: . + required: true + build-args: + description: 'List of build-time variables' + required: false + +outputs: + image: + description: 'Image url' + value: ${{ steps.imageOuput.outputs.imageUrl }} + imageid: + description: 'Image ID' + value: ${{ steps.publish.outputs.imageId }} + digest: + description: 'Image digest' + value: ${{ steps.publish.outputs.digest }} + metadata: + description: 'Build result metadata' + value: ${{ steps.publish.outputs.metadata }} + +runs: + using: 'composite' + steps: + - name: Log in to the ghcr.io registry + uses: docker/login-action@v2 + with: + registry: ${{ inputs.registry }} + username: ${{ inputs.username }} + password: ${{ inputs.password }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + ${{ inputs.image }} + tags: | + type=ref,event=branch + type=sha,prefix= + type=semver,pattern={{raw}} + flavor: | + latest=${{ github.ref == 'refs/heads/master' }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build and push the image to ghcr.io + uses: docker/build-push-action@v4 + id: publish + with: + context: ${{ inputs.context }} + platforms: linux/amd64 + file: ${{ inputs.dockerfile }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: ${{ inputs.build-args }} + cache-from: type=gha + cache-to: type=gha,mode=max + - id: imageOuput + shell: bash + run: | + echo "imageUrl=${{ fromJSON(steps.publish.outputs.metadata)['image.name'] }}" >> $GITHUB_OUTPUT diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..cab53a5 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,32 @@ +name: Build ad publish Docker image + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize] + release: + types: [published] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + build-and-publish-image: + runs-on: buildjet-4vcpu-ubuntu-2204 + if: | + (github.event_name == 'release' && github.event.action == 'published') || + github.ref == 'refs/heads/main' || github.event_name == 'pull_request' + steps: + - uses: actions/checkout@v3 + + - name: Build and push Fuel Graph Node Image + uses: ./.github/actions/docker-publish + id: publish + with: + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + image: ghcr.io/fuellabs/fuel-graph-node + dockerfile: fuel-graph-node/Dockerfile \ No newline at end of file diff --git a/fuel-graph-node/Cargo.lock b/fuel-graph-node/Cargo.lock index a717583..a35fafb 100644 --- a/fuel-graph-node/Cargo.lock +++ b/fuel-graph-node/Cargo.lock @@ -160,16 +160,6 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eab1c04a571841102f5345a8fc0f6bb3d31c315dec879b5c6e42e40ce7ffa34e" -[[package]] -name = "assert-json-diff" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "async-recursion" version = "1.0.5" @@ -1840,21 +1830,6 @@ dependencies = [ "syn 1.0.107", ] -[[package]] -name = "graph-runtime-test" -version = "0.33.0" -dependencies = [ - "graph", - "graph-chain-ethereum", - "graph-core", - "graph-runtime-derive", - "graph-runtime-wasm", - "rand", - "semver", - "test-store", - "wasmtime", -] - [[package]] name = "graph-runtime-wasm" version = "0.33.0" @@ -1987,34 +1962,6 @@ dependencies = [ "uuid", ] -[[package]] -name = "graph-tests" -version = "0.33.0" -dependencies = [ - "anyhow", - "assert-json-diff", - "async-stream", - "futures 0.3.16", - "graph", - "graph-chain-ethereum", - "graph-chain-substreams", - "graph-core", - "graph-graphql", - "graph-node", - "graph-runtime-wasm", - "graph-server-index-node", - "graph-store-postgres", - "graphql-parser", - "hyper", - "secp256k1", - "serde", - "serde_yaml", - "slog", - "termcolor", - "tokio", - "tokio-stream", -] - [[package]] name = "graphql-parser" version = "0.4.0" @@ -4484,26 +4431,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "test-store" -version = "0.33.0" -dependencies = [ - "diesel", - "graph", - "graph-chain-ethereum", - "graph-core", - "graph-graphql", - "graph-node", - "graph-store-postgres", - "graphql-parser", - "hex", - "hex-literal 0.4.1", - "lazy_static", - "pretty_assertions", - "prost-types", - "serde", -] - [[package]] name = "textwrap" version = "0.16.0" diff --git a/fuel-graph-node/Cargo.toml b/fuel-graph-node/Cargo.toml index 1b49e8b..409dd1c 100644 --- a/fuel-graph-node/Cargo.toml +++ b/fuel-graph-node/Cargo.toml @@ -4,12 +4,12 @@ members = [ "chain/*", "graphql", "node", - "runtime/*", + "runtime/derive", + "runtime/wasm", "server/*", - "store/*", + "store/postgres", "substreams/*", "graph", - "tests", ] [workspace.package] diff --git a/fuel-graph-node/Dockerfile b/fuel-graph-node/Dockerfile new file mode 100644 index 0000000..3bcdaa2 --- /dev/null +++ b/fuel-graph-node/Dockerfile @@ -0,0 +1,58 @@ + +FROM rust:bullseye as graph-node-build + +WORKDIR /app + +RUN apt update && apt install -y protobuf-compiler +COPY ./fuel-graph-node /app/fuel-graph-node +RUN cd /app/fuel-graph-node && cargo build --release + +# The graph-node runtime image with only the executable +FROM debian:bullseye-slim as graph-node +ENV RUST_LOG "" +ENV GRAPH_LOG "" +ENV EARLY_LOG_CHUNK_SIZE "" + +ENV postgres_host "" +ENV postgres_user "" +ENV postgres_pass "" +ENV postgres_db "" +ENV postgres_args "sslmode=prefer" +# The full URL to the IPFS node +ENV ipfs "" +# The etherum network(s) to connect to. Set this to a space-separated +# list of the networks where each entry has the form NAME:URL +ENV ethereum "" +# The role the node should have, one of index-node, query-node, or +# combined-node +ENV node_role "combined-node" +# The name of this node +ENV node_id "default" +# The ethereum network polling interval (in milliseconds) +ENV ethereum_polling_interval "" + +# The location of an optional configuration file for graph-node, as +# described in ../docs/config.md +# Using a configuration file is experimental, and the file format may +# change in backwards-incompatible ways +ENV GRAPH_NODE_CONFIG "" + +# Disable core dumps; this is useful for query nodes with large caches. Set +# this to anything to disable coredumps (via 'ulimit -c 0') +ENV disable_core_dumps "" + +# HTTP port +EXPOSE 8000 +# WebSocket port +EXPOSE 8001 +# JSON-RPC port +EXPOSE 8020 +# Indexing status port +EXPOSE 8030 + +RUN apt-get update \ + && apt-get install -y libpq-dev ca-certificates netcat + +COPY --from=graph-node-build /app/fuel-graph-node/target/release/graph-node /app/graph-node + +CMD ["/app/graph-node"]