added fantom

This commit is contained in:
cventastic
2022-05-11 10:34:34 +02:00
parent 27862bf4c9
commit 8ac4b09771
3 changed files with 96 additions and 0 deletions

30
fantom.yml Normal file
View File

@@ -0,0 +1,30 @@
version: "3.4"
services:
fantom:
build:
args:
VERSION: release/1.1.0-rc.4
context: ./fantom
dockerfile: Dockerfile
environment:
- SNAPSHOT_URL=https://download.fantom.network/opera_5may22.tgz
volumes:
- "fantom:/datadir"
expose:
# API PORTS https://github.com/Fantom-foundation/go-opera/wiki/API
# - "18545:18545"
# - "18546:18546"
# RPC-PORT
- "5050"
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.middlewares.fantom-stripprefix.stripprefix.prefixes=/fantom"
- "traefik.http.services.fantom.loadbalancer.server.port=8545"
- "traefik.http.routers.fantom.entrypoints=websecure"
- "traefik.http.routers.fantom.tls.certresolver=myresolver"
- "traefik.http.routers.fantom.rule=Host(`$DOMAIN`) && PathPrefix(`/fantom`)"
- "traefik.http.routers.fantom.middlewares=fantom-stripprefix, ipwhitelist"
volumes:
fantom:

28
fantom/Dockerfile Normal file
View File

@@ -0,0 +1,28 @@
# Build Fantom in a stock Go builder container
FROM golang:1.17-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
# Clone the repo to that folder
RUN git clone --branch ${VERSION} 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/
# Set entrypoint
COPY ./scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod u+x /usr/local/bin/entrypoint.sh
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]

View File

@@ -0,0 +1,38 @@
#!/bin/sh
# exit script on any error
set -e
# Set fantom Home Directory
FANTOM_HOME=/datadir
if [ -n "${SNAPSHOT_URL}" ] && [ ! -f "${FANTOM_HOME}/bootstrapped" ];
then
echo "downloading snapshot from ${SNAPSHOT_URL}"
wget --tries=0 -O - "${SNAPSHOT_URL}" | tar -xz --strip-components=1 -C ${FANTOM_HOME}/ && touch ${FANTOM_HOME}/bootstrapped
fi
if [ ! -f "$FANTOM_HOME/mainnet.g" ];
then
cd $FANTOM_HOME
echo "downloading launch genesis file"
wget --quiet https://opera.fantom.network/mainnet.g
fi
opera \
--genesis=/datadir/mainnet.g \
--port=5050 \
--maxpeers=200 \
--datadir=/datadir \
--http \
--http.addr=0.0.0.0 \
--http.port=18545 \
--http.api=ftm,eth,debug,admin,web3,personal,net,txpool,sfc \
--http.corsdomain="*" \
--http.vhosts="*" \
--ws \
--ws.addr=0.0.0.0 \
--ws.port=18546 \
--ws.api=ftm,eth,debug,admin,web3,personal,net,txpool,sfc \
--ws.origins="*" \
--nousb