diff --git a/fantom/Dockerfile.opera b/fantom/Dockerfile.opera new file mode 100644 index 00000000..ab4b641b --- /dev/null +++ b/fantom/Dockerfile.opera @@ -0,0 +1,30 @@ +# Build Fantom in a stock Go builder container +FROM golang:1.19-alpine as builder + +# Install packages we need +RUN apk add --no-cache make gcc musl-dev linux-headers git + +# Make a folder to work in +RUN mkdir /fantom + +# Grab VERSION from Build Args +ARG VERSION +ARG REPO + +# Clone the repo to that folder +RUN git clone --branch ${VERSION} ${REPO:-https://github.com/Fantom-foundation/go-opera.git} /fantom + +# Build Fantom +RUN cd /fantom && make + +# Pull Fantom into a second stage deploy alpine container +FROM alpine:latest + +RUN apk add --no-cache ca-certificates wget tzdata +COPY --from=builder /fantom/build/opera /usr/local/bin/ + +VOLUME /datadir + +COPY ./scripts/entrypoint.opera.sh /usr/local/bin/entrypoint.sh +RUN chmod u+x /usr/local/bin/entrypoint.sh +ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ] diff --git a/fantom/opera/fantom-mainnet-opera-archive.yml b/fantom/opera/fantom-mainnet-opera-archive.yml new file mode 100644 index 00000000..ee8df598 --- /dev/null +++ b/fantom/opera/fantom-mainnet-opera-archive.yml @@ -0,0 +1,54 @@ +services: + fantom-mainnet-archive: + build: + context: ./fantom + dockerfile: Dockerfile.opera + args: + VERSION: "${FANTOM_OPERA_VERSION:-v1.1.3-rc.5}" + REPO: "https://github.com/Fantom-foundation/go-opera.git" + stop_grace_period: 3m + volumes: + - "fantom-mainnet-opera-archive:/datadir" + expose: + - "8545" + ports: + - "10723:10723" + - "10723:10723/udp" + networks: + - chains + environment: + - "IP=${IP}" + - "GENESIS=https://download.fantom.network/opera/mainnet/mainnet-5577-full-mpt.g" + restart: unless-stopped + command: > + --port=10723 + --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,sfc + --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,sfc + --ws.origins="*" + --rpc.gascap=600000000 + --db.migration.mode reformat + --db.preset pbl-1 + --cache=${FANTOM_MAINNET_OPERA_ARCHIVE_CACHE_MB:-16000} + + --bootnodes=enode://94dfec3eb6e50187d22d12f7dd965169bab5a63022934ef0b3b82a819574e0940b5bcb471f62360f1b58cf61a89e634bd14ae7c2e29ce48088890f4a7aff44fe@75.98.207.227:5050,enode://7fb3f43273f4dfeb19c3129c6ed999e14246d2f219ff284d0ef87417cd9514c6d542abc988a654b4a77005ea896c5b4e4ca0d40f97f3bf9ee37be33cc749835f@209.172.40.68:5050,enode://27a80a1db08a40636415d4ff9bb272882b6a6f97a9a5d596006de843f35cbbc679e5252d89d3de05bd74c36cf9f5ce2446dd66cdd5dc7e942a585eb4add61124@37.27.70.18:5050,enode://946fef1538abd165f8bd2ae1c290e7689ff5e209ab6c085eaced9b91e93684b1efe05f79a9a9b460504c450065baaeda5ecb72c03f8adf7e7a559042ce4950da@136.243.252.124:5078,enode://cf762e3a68f8a96676d6383cd3286b85ef7454ef37bb39283efe00d3d573d88f05db3daab7c35a4d3ba9edd9d089e359a25de5beeb24f79f6c1b9e5341958cee@15.235.54.211:5050 + labels: + - "traefik.enable=true" + - "traefik.http.middlewares.fantom-mainnet-opera-archive-stripprefix.stripprefix.prefixes=/fantom-mainnet-archive" + - "traefik.http.services.fantom-mainnet-opera-archive.loadbalancer.server.port=8545" + - "traefik.http.routers.fantom-mainnet-opera-archive.entrypoints=websecure" + - "traefik.http.routers.fantom-mainnet-opera-archive.tls.certresolver=myresolver" + - "traefik.http.routers.fantom-mainnet-opera-archive.rule=Host(`$DOMAIN`) && PathPrefix(`/fantom-mainnet-archive`)" + - "traefik.http.routers.fantom-mainnet-opera-archive.middlewares=fantom-mainnet-opera-archive-stripprefix, ipwhitelist" + +volumes: + fantom-mainnet-opera-archive: \ No newline at end of file diff --git a/fantom/opera/fantom-mainnet-opera-pruned.yml b/fantom/opera/fantom-mainnet-opera-pruned.yml new file mode 100644 index 00000000..81457aac --- /dev/null +++ b/fantom/opera/fantom-mainnet-opera-pruned.yml @@ -0,0 +1,54 @@ +services: + fantom-mainnet: + build: + context: ./fantom + dockerfile: Dockerfile.opera + args: + VERSION: "${FANTOM_OPERA_VERSION:-v1.1.3-rc.5}" + REPO: "https://github.com/Fantom-foundation/go-opera.git" + stop_grace_period: 3m + volumes: + - "fantom-mainnet-opera-pruned:/datadir" + expose: + - "8545" + ports: + - "10439:10439" + - "10439:10439/udp" + networks: + - chains + environment: + - "IP=${IP}" + - "GENESIS=https://download.fantom.network/opera/mainnet/mainnet-109331-no-history.g" + restart: unless-stopped + command: > + --port=10439 + --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,sfc + --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,sfc + --ws.origins="*" + --rpc.gascap=600000000 + --db.migration.mode reformat + --db.preset pbl-1 + --cache=${FANTOM_MAINNET_OPERA_PRUNED_CACHE_MB:-16000} + + --bootnodes=enode://94dfec3eb6e50187d22d12f7dd965169bab5a63022934ef0b3b82a819574e0940b5bcb471f62360f1b58cf61a89e634bd14ae7c2e29ce48088890f4a7aff44fe@75.98.207.227:5050,enode://7fb3f43273f4dfeb19c3129c6ed999e14246d2f219ff284d0ef87417cd9514c6d542abc988a654b4a77005ea896c5b4e4ca0d40f97f3bf9ee37be33cc749835f@209.172.40.68:5050,enode://27a80a1db08a40636415d4ff9bb272882b6a6f97a9a5d596006de843f35cbbc679e5252d89d3de05bd74c36cf9f5ce2446dd66cdd5dc7e942a585eb4add61124@37.27.70.18:5050,enode://946fef1538abd165f8bd2ae1c290e7689ff5e209ab6c085eaced9b91e93684b1efe05f79a9a9b460504c450065baaeda5ecb72c03f8adf7e7a559042ce4950da@136.243.252.124:5078,enode://cf762e3a68f8a96676d6383cd3286b85ef7454ef37bb39283efe00d3d573d88f05db3daab7c35a4d3ba9edd9d089e359a25de5beeb24f79f6c1b9e5341958cee@15.235.54.211:5050 + labels: + - "traefik.enable=true" + - "traefik.http.middlewares.fantom-mainnet-opera-pruned-stripprefix.stripprefix.prefixes=/fantom-mainnet" + - "traefik.http.services.fantom-mainnet-opera-pruned.loadbalancer.server.port=8545" + - "traefik.http.routers.fantom-mainnet-opera-pruned.entrypoints=websecure" + - "traefik.http.routers.fantom-mainnet-opera-pruned.tls.certresolver=myresolver" + - "traefik.http.routers.fantom-mainnet-opera-pruned.rule=Host(`$DOMAIN`) && PathPrefix(`/fantom-mainnet`)" + - "traefik.http.routers.fantom-mainnet-opera-pruned.middlewares=fantom-mainnet-opera-pruned-stripprefix, ipwhitelist" + +volumes: + fantom-mainnet-opera-pruned: \ No newline at end of file diff --git a/fantom/opera/fantom-testnet-opera-archive.yml b/fantom/opera/fantom-testnet-opera-archive.yml new file mode 100644 index 00000000..07ff421c --- /dev/null +++ b/fantom/opera/fantom-testnet-opera-archive.yml @@ -0,0 +1,54 @@ +services: + fantom-testnet-archive: + build: + context: ./fantom + dockerfile: Dockerfile.opera + args: + VERSION: "${FANTOM_OPERA_VERSION:-v1.1.3-rc.5}" + REPO: "https://github.com/Fantom-foundation/go-opera.git" + stop_grace_period: 3m + volumes: + - "fantom-testnet-opera-archive:/datadir" + expose: + - "8545" + ports: + - "10055:10055" + - "10055:10055/udp" + networks: + - chains + environment: + - "IP=${IP}" + - "GENESIS=https://download.fantom.network/opera/testnet/testnet-2458-full-mpt.g" + restart: unless-stopped + command: > + --port=10055 + --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,sfc + --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,sfc + --ws.origins="*" + --rpc.gascap=600000000 + --db.migration.mode reformat + --db.preset pbl-1 + --cache=${FANTOM_TESTNET_OPERA_ARCHIVE_CACHE_MB:-16000} + + --bootnodes=enode://2411cdad2780bf969c0bd6f19b53ac6683710d50f19a7604248d8a6a810d3d6369dffb08535530095c151ecad143393e4fbca2d11f62377fe15b3df4d9883053@34.172.30.235:5050,enode://6f434dc43f826f7c3c817ba7fbe7842aa47c50d1e77a6b57ec51313fd88c7f006240baa105b795712922a05e1b548d413ea6d32d8c1c8feb9ffc206a6c9e37ce@34.55.131.153:5050,enode://64e69ec1f30be48aa8d5f3e6cadf15d06d846d40918f3906e6efbc4a3421f0cc04e3e4f88569b5c90306bbc16ca15df6898ad71b8a73aa36284f1c3076f2956e@35.195.64.211:5050,enode://a76d94105f12d3fb5c31df5a59448d95b723d94543620a02f72ee990e048c43df940f4969ab06d436ef8976c49ec9c2a671c2f5af8d93af911cef63de329a8b8@35.239.100.93:5050,enode://baea3b72d091cb361283af4933da32406d707d3bb077a42c77a58cf98e27b546da837e6e9524d8588f414e1886a3b17e036b86fd2d723170db93831a22324252@35.241.219.197:5050,enode://544f06ceaddcf508a13326d95518a524e14f4980723c9dc5cb8560635a7faa7f8f91483faed19dacd7d251abf72b4a1b0bcacaced1255deb93414d097221a9bc@35.224.88.189:5050,enode://baea3b72d091cb361283af4933da32406d707d3bb077a42c77a58cf98e27b546da837e6e9524d8588f414e1886a3b17e036b86fd2d723170db93831a22324252@35.241.219.197:5050,enode://2cd3fcfe9671d81c0e8bb76bc81a430882ce5d99199c20a004da97bec48e9b03c02c3b6d95edb77498ce2dd8e090c4ce76349e775af7540b04a6e9303e5b69cd@104.155.31.23:5050 + labels: + - "traefik.enable=true" + - "traefik.http.middlewares.fantom-testnet-opera-archive-stripprefix.stripprefix.prefixes=/fantom-testnet-archive" + - "traefik.http.services.fantom-testnet-opera-archive.loadbalancer.server.port=8545" + - "traefik.http.routers.fantom-testnet-opera-archive.entrypoints=websecure" + - "traefik.http.routers.fantom-testnet-opera-archive.tls.certresolver=myresolver" + - "traefik.http.routers.fantom-testnet-opera-archive.rule=Host(`$DOMAIN`) && PathPrefix(`/fantom-testnet-archive`)" + - "traefik.http.routers.fantom-testnet-opera-archive.middlewares=fantom-testnet-opera-archive-stripprefix, ipwhitelist" + +volumes: + fantom-testnet-opera-archive: \ No newline at end of file diff --git a/fantom/opera/fantom-testnet-opera-pruned.yml b/fantom/opera/fantom-testnet-opera-pruned.yml new file mode 100644 index 00000000..c74c30f0 --- /dev/null +++ b/fantom/opera/fantom-testnet-opera-pruned.yml @@ -0,0 +1,54 @@ +services: + fantom-testnet: + build: + context: ./fantom + dockerfile: Dockerfile.opera + args: + VERSION: "${FANTOM_OPERA_VERSION:-v1.1.3-rc.5}" + REPO: "https://github.com/Fantom-foundation/go-opera.git" + stop_grace_period: 3m + volumes: + - "fantom-testnet-opera-pruned:/datadir" + expose: + - "8545" + ports: + - "10846:10846" + - "10846:10846/udp" + networks: + - chains + environment: + - "IP=${IP}" + - "GENESIS=https://download.fantom.network/opera/testnet/testnet-6226-no-history.g" + restart: unless-stopped + command: > + --port=10846 + --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,sfc + --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,sfc + --ws.origins="*" + --rpc.gascap=600000000 + --db.migration.mode reformat + --db.preset pbl-1 + --cache=${FANTOM_TESTNET_OPERA_PRUNED_CACHE_MB:-16000} + + --bootnodes=enode://2411cdad2780bf969c0bd6f19b53ac6683710d50f19a7604248d8a6a810d3d6369dffb08535530095c151ecad143393e4fbca2d11f62377fe15b3df4d9883053@34.172.30.235:5050,enode://6f434dc43f826f7c3c817ba7fbe7842aa47c50d1e77a6b57ec51313fd88c7f006240baa105b795712922a05e1b548d413ea6d32d8c1c8feb9ffc206a6c9e37ce@34.55.131.153:5050,enode://64e69ec1f30be48aa8d5f3e6cadf15d06d846d40918f3906e6efbc4a3421f0cc04e3e4f88569b5c90306bbc16ca15df6898ad71b8a73aa36284f1c3076f2956e@35.195.64.211:5050,enode://a76d94105f12d3fb5c31df5a59448d95b723d94543620a02f72ee990e048c43df940f4969ab06d436ef8976c49ec9c2a671c2f5af8d93af911cef63de329a8b8@35.239.100.93:5050,enode://baea3b72d091cb361283af4933da32406d707d3bb077a42c77a58cf98e27b546da837e6e9524d8588f414e1886a3b17e036b86fd2d723170db93831a22324252@35.241.219.197:5050,enode://544f06ceaddcf508a13326d95518a524e14f4980723c9dc5cb8560635a7faa7f8f91483faed19dacd7d251abf72b4a1b0bcacaced1255deb93414d097221a9bc@35.224.88.189:5050,enode://baea3b72d091cb361283af4933da32406d707d3bb077a42c77a58cf98e27b546da837e6e9524d8588f414e1886a3b17e036b86fd2d723170db93831a22324252@35.241.219.197:5050,enode://2cd3fcfe9671d81c0e8bb76bc81a430882ce5d99199c20a004da97bec48e9b03c02c3b6d95edb77498ce2dd8e090c4ce76349e775af7540b04a6e9303e5b69cd@104.155.31.23:5050 + labels: + - "traefik.enable=true" + - "traefik.http.middlewares.fantom-testnet-opera-pruned-stripprefix.stripprefix.prefixes=/fantom-testnet" + - "traefik.http.services.fantom-testnet-opera-pruned.loadbalancer.server.port=8545" + - "traefik.http.routers.fantom-testnet-opera-pruned.entrypoints=websecure" + - "traefik.http.routers.fantom-testnet-opera-pruned.tls.certresolver=myresolver" + - "traefik.http.routers.fantom-testnet-opera-pruned.rule=Host(`$DOMAIN`) && PathPrefix(`/fantom-testnet`)" + - "traefik.http.routers.fantom-testnet-opera-pruned.middlewares=fantom-testnet-opera-pruned-stripprefix, ipwhitelist" + +volumes: + fantom-testnet-opera-pruned: \ No newline at end of file diff --git a/fantom/scripts/entrypoint.opera.sh b/fantom/scripts/entrypoint.opera.sh new file mode 100644 index 00000000..eedb3c1d --- /dev/null +++ b/fantom/scripts/entrypoint.opera.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +# exit script on any error +set -e + +datadir=/datadir +FANTOM_HOME="$datadir" + +url="${GENESIS:-https://download.fantom.network/opera/mainnet/mainnet-5577-full-mpt.g}" +filename=$(basename "$url") + +if [ ! -f "$datadir/bootstrapped" ]; then + echo "Initializing Opera..." + + if [ ! -f "$datadir/$filename" ]; then + wget -P "$datadir" "$url" + fi + + touch "$datadir/bootstrapped" + + echo "Initialization complete." +else + echo "Opera is already initialized." +fi + +# uncomment the next line and do docker-compose build in case you have to try to fix the db after unclean shutdown etc. +# opera --db.preset pbl-1 --datadir=$datadir db heal --experimental + +# always make a new nodekey + +echo "Generating new Geth node key..." +openssl rand 32 | xxd -p -c 32 | tr -d '\n' > "$datadir/nodekey" + +exec opera --nodekey="$datadir/nodekey" --genesis="$datadir/$filename" --datadir="$datadir" "$@"