Skip to content

Commit

Permalink
🗞️ Aptos node image (#1011)
Browse files Browse the repository at this point in the history
  • Loading branch information
janjakubnanista authored Nov 13, 2024
1 parent 01dff6a commit 4545c8f
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/reusable-publish-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,47 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

#
# Build the Aptos node image and push it as digests
#
# We build the node images after we're done with the base so that we can use the docker layer cache
# instead of rebuilding the whole thing from scratch
#
build-node-aptos:
name: Build Aptos node image
runs-on: ubuntu-latest-16xlarge
needs:
- build-base

permissions:
contents: read
packages: write

strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build image & push the digest
uses: ./.github/workflows/actions/docker-build-image
with:
# The name of the image
image: devtools-dev-node-aptos-local-testnet
# The target stage of the Dockerfile
target: node-aptos-local-testnet
# Since the digests will be shared across jobs as artifacts,
# we need a unique name (per workflow) for these artifacts
digest-name: node-aptos-local-testnet
platform: ${{ matrix.platform }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

#
# Build the EVM node image and push it as digests
#
Expand Down Expand Up @@ -131,6 +172,7 @@ jobs:
platform: ${{ matrix.platform }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

#
# Build the TON node image and push it as digests
#
Expand Down Expand Up @@ -198,6 +240,32 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

#
# Collect the Aptos node image digests and push them to GHCR
#
push-node-aptos:
name: Push Aptos node image
runs-on: ubuntu-latest-4xlarge
needs:
- build-node-aptos

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Push image
uses: ./.github/workflows/actions/docker-push-image
with:
# The name of the image
image: devtools-dev-node-aptos-local-testnet
# Since the digests will be shared across jobs as artifacts,
# we need a unique name (per workflow) for these artifacts
#
# This needs to match the digest name of the build stage
digest-name: node-aptos-local-testnet
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

#
# Collect the EVM node image digests and push them to GHCR
#
Expand Down
45 changes: 45 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ ARG NODE_VERSION=20.10.0
# e.g. ghcr.io/layerzero-labs/devtools-dev-base:main
ARG BASE_IMAGE=base

# We will provide a way for consumers to override the default Aptos node image
#
# This will allow CI environments to supply the prebuilt EVM node image
# while not breaking the flow for local development
ARG APTOS_NODE_IMAGE=node-aptos-local-testnet

# We will provide a way for consumers to override the default EVM node image
#
# This will allow CI environments to supply the prebuilt EVM node image
Expand Down Expand Up @@ -353,6 +359,34 @@ RUN \
# Install dependencies (fail if we forgot to update the lockfile)
pnpm install --recursive --offline --frozen-lockfile

# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'
#
# Image that builds an Aptos node
#
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'
FROM machine AS node-aptos-local-testnet

ENV PATH="/root/.aptos/bin:$PATH"

# Get aptos CLI
COPY --from=aptos /root/.aptos/bin /root/.aptos/bin

# We'll provide a default healthcheck by asking for the chain information
HEALTHCHECK --interval=2s --retries=20 CMD curl -f http://0.0.0.0:8080/v1 || exit 1

# By default, Aptos exposes the following ports:
#
# Node API 8080
# Transaction stream 50051
# Faucet is ready 8081
ENTRYPOINT aptos

Check warning on line 386 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Aptos node image (linux/amd64)

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for ENTRYPOINT to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/

Check warning on line 386 in Dockerfile

View workflow job for this annotation

GitHub Actions / Build Aptos node image (linux/arm64)

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for ENTRYPOINT to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/

CMD ["node", "run-local-testnet", "--force-restart", "--assume-yes"]

# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'
Expand Down Expand Up @@ -504,6 +538,17 @@ RUN solana-test-validator --version
# WebSocket: 8900
ENTRYPOINT ["solana-test-validator"]

# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'
#
# Image that runs an Aptos node
#
# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'
FROM $APTOS_NODE_IMAGE AS node-aptos

# .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-. .-.-
# / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \ \ / / \
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ services:
# Expose nodes on host ports
#
# .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
network-aptos:
ports:
# The Node API
- "10004:8080"
# The faucet API
- "10005:8081"

network-vengaboys:
ports:
- "10001:8545"
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ services:
max-size: "5m"
compress: "false"

# Aptos node for testing purposes
aptos-node:
build:
dockerfile: Dockerfile
target: node-aptos
args:
APTOS_NODE_IMAGE: ${DEVTOOLS_APTOS_NODE_IMAGE:-node-aptos-local-testnet}

logging:
driver: local
options:
max-size: "5m"
compress: "false"

# EVM node for testing purposes
evm-node:
extends:
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
# `-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-' `-`-'

services:
# ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~
#
# The Aptos local node
#
# .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
# TODO This node is not yet made a dependency of the tests container
# since we don't have any tests running against Aptos
network-aptos:
extends:
file: docker-compose.templates.yaml
service: aptos-node

# ~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~^~
#
# EVM Network nodes, one for every hardhat network
Expand Down

0 comments on commit 4545c8f

Please sign in to comment.