From 1056feab7ec4c763b7dc5c951302b85bd7144cb4 Mon Sep 17 00:00:00 2001 From: squidbear <379651+czarly@users.noreply.github.com> Date: Tue, 25 Mar 2025 09:22:58 +0100 Subject: [PATCH] do fantom with sonic as well --- fantom/Dockerfile.sonic | 26 ++++++++++ fantom/scripts/entrypoint.sonic.sh | 23 +++++++++ fantom/sonic/fantom-mainnet-sonic-archive.yml | 51 +++++++++++++++++++ fantom/sonic/fantom-testnet-sonic-archive.yml | 51 +++++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 fantom/Dockerfile.sonic create mode 100644 fantom/scripts/entrypoint.sonic.sh create mode 100644 fantom/sonic/fantom-mainnet-sonic-archive.yml create mode 100644 fantom/sonic/fantom-testnet-sonic-archive.yml diff --git a/fantom/Dockerfile.sonic b/fantom/Dockerfile.sonic new file mode 100644 index 00000000..d111cb4f --- /dev/null +++ b/fantom/Dockerfile.sonic @@ -0,0 +1,26 @@ +FROM golang:1.22 as builder + +ARG VERSION +ARG REPO + +RUN apt-get update && apt-get install -y git musl-dev make + +RUN cd /go && git clone ${REPO:-https://github.com/Fantom-foundation/sonic.git} sonic && cd sonic && git fetch --tags && git checkout -b ${VERSION} tags/${VERSION} + +WORKDIR /go/sonic + +ARG GOPROXY +RUN go mod download +RUN make all + +FROM golang:1.22 + +COPY --from=builder /go/sonic/build/sonicd /usr/local/bin/ +COPY --from=builder /go/sonic/build/sonictool /usr/local/bin/ + +COPY ./scripts/entrypoint.sonic.sh /usr/local/bin/entrypoint.sh + +VOLUME /var/sonic + +RUN chmod u+x /usr/local/bin/entrypoint.sh +ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ] diff --git a/fantom/scripts/entrypoint.sonic.sh b/fantom/scripts/entrypoint.sonic.sh new file mode 100644 index 00000000..fe011122 --- /dev/null +++ b/fantom/scripts/entrypoint.sonic.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +datadir=/var/sonic + +if [ ! -f "$datadir/initialized" ]; then + echo "Initializing Sonic..." + + url="${GENESIS:-https://download.fantom.network/opera/mainnet/mainnet-5577-archive.g}" + filename=$(basename "$url") + + wget -P "$datadir" "$url" + + GOMEMLIMIT="${CACHE_GB}GiB" sonictool --datadir "$datadir" --cache "${CACHE_GB}000" genesis "$datadir/$filename" + rm "$datadir/$filename" + + touch "$datadir/initialized" + + echo "Initialization complete." +else + echo "Sonic is already initialized." +fi + +exec sonicd --cache "${CACHE_GB}000" --datadir "$datadir" "$@" diff --git a/fantom/sonic/fantom-mainnet-sonic-archive.yml b/fantom/sonic/fantom-mainnet-sonic-archive.yml new file mode 100644 index 00000000..fe4c9324 --- /dev/null +++ b/fantom/sonic/fantom-mainnet-sonic-archive.yml @@ -0,0 +1,51 @@ +services: + fantom-mainnet-archive: + build: + context: ./fantom + dockerfile: Dockerfile.sonic + args: + VERSION: "${FANTOM_SONIC_VERSION:-v1.2.1-h}" + REPO: "https://github.com/Fantom-foundation/sonic.git" + stop_grace_period: 3m + volumes: + - "fantom-mainnet-sonic-archive:/var/sonic" + expose: + - "8545" + ports: + - "10335:10335" + - "10335:10335/udp" + networks: + - chains + environment: + - "IP=${IP}" + - "GENESIS=https://download.fantom.network/mainnet-latest-archive.g" + - "CACHE_GB=${FANTOM_MAINNET_SONIC_CACHE_GB:-28}" + restart: unless-stopped + command: > + --port=10335 + --nat=extip:${IP} + --maxpeers=200 + --http + --http.addr=0.0.0.0 + --http.port=8545 + --http.api=admin,debug,web3,eth,dag,txpool,personal,abft,net,trace,ftm + --http.corsdomain="*" + --http.vhosts="*" + --ws + --ws.addr=0.0.0.0 + --ws.port=8545 + --ws.api=admin,debug,web3,eth,dag,txpool,personal,abft,net,trace,ftm + --ws.origins="*" + --rpc.gascap=600000000 + + labels: + - "traefik.enable=true" + - "traefik.http.middlewares.fantom-mainnet-sonic-archive-stripprefix.stripprefix.prefixes=/fantom-mainnet-archive" + - "traefik.http.services.fantom-mainnet-sonic-archive.loadbalancer.server.port=18544" + - "traefik.http.routers.fantom-mainnet-sonic-archive.entrypoints=websecure" + - "traefik.http.routers.fantom-mainnet-sonic-archive.tls.certresolver=myresolver" + - "traefik.http.routers.fantom-mainnet-sonic-archive.rule=Host(`$DOMAIN`) && PathPrefix(`/fantom-mainnet-archive`)" + - "traefik.http.routers.fantom-mainnet-sonic-archive.middlewares=fantom-mainnet-sonic-archive-stripprefix, ipwhitelist" + +volumes: + fantom-mainnet-sonic-archive: \ No newline at end of file diff --git a/fantom/sonic/fantom-testnet-sonic-archive.yml b/fantom/sonic/fantom-testnet-sonic-archive.yml new file mode 100644 index 00000000..72c2598a --- /dev/null +++ b/fantom/sonic/fantom-testnet-sonic-archive.yml @@ -0,0 +1,51 @@ +services: + fantom-testnet-archive: + build: + context: ./fantom + dockerfile: Dockerfile.sonic + args: + VERSION: "${FANTOM_SONIC_VERSION:-v1.2.1-h}" + REPO: "https://github.com/Fantom-foundation/sonic.git" + stop_grace_period: 3m + volumes: + - "fantom-testnet-sonic-archive:/var/sonic" + expose: + - "8545" + ports: + - "10652:10652" + - "10652:10652/udp" + networks: + - chains + environment: + - "IP=${IP}" + - "GENESIS=https://download.fantom.network/opera/testnet/testnet-26650-rpc.g" + - "CACHE_GB=${FANTOM_TESTNET_SONIC_CACHE_GB:-28}" + restart: unless-stopped + command: > + --port=10652 + --nat=extip:${IP} + --maxpeers=200 + --http + --http.addr=0.0.0.0 + --http.port=8545 + --http.api=admin,debug,web3,eth,dag,txpool,personal,abft,net,trace,ftm + --http.corsdomain="*" + --http.vhosts="*" + --ws + --ws.addr=0.0.0.0 + --ws.port=8545 + --ws.api=admin,debug,web3,eth,dag,txpool,personal,abft,net,trace,ftm + --ws.origins="*" + --rpc.gascap=600000000 + + labels: + - "traefik.enable=true" + - "traefik.http.middlewares.fantom-testnet-sonic-archive-stripprefix.stripprefix.prefixes=/fantom-testnet-archive" + - "traefik.http.services.fantom-testnet-sonic-archive.loadbalancer.server.port=18544" + - "traefik.http.routers.fantom-testnet-sonic-archive.entrypoints=websecure" + - "traefik.http.routers.fantom-testnet-sonic-archive.tls.certresolver=myresolver" + - "traefik.http.routers.fantom-testnet-sonic-archive.rule=Host(`$DOMAIN`) && PathPrefix(`/fantom-testnet-archive`)" + - "traefik.http.routers.fantom-testnet-sonic-archive.middlewares=fantom-testnet-sonic-archive-stripprefix, ipwhitelist" + +volumes: + fantom-testnet-sonic-archive: \ No newline at end of file