diff --git a/Dockerfile b/Dockerfile index 88005b0..fe321d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,9 +13,9 @@ RUN GCO_ENABLED=0 GOOS=linux go build -race -ldflags="-s -w" -o ipld-eth-beacon- RUN chmod +x ipld-eth-beacon-indexer FROM frolvlad/alpine-bash:latest -RUN apk --no-cache add ca-certificates libstdc++ busybox-extras +RUN apk --no-cache add ca-certificates libstdc++ busybox-extras gettext libintl WORKDIR /root/ COPY --from=builder /go/src/github.com/vulcanize/ipld-eth-beacon-indexer/ipld-eth-beacon-indexer /root/ipld-eth-beacon-indexer ADD entrypoint.sh . -ADD ipld-eth-beacon-config.json . +ADD ipld-eth-beacon-config-docker.json . ENTRYPOINT ["./entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c57e85b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +version: "3.2" +services: + ipld-eth-beacon-db: + hostname: ipld-eth-beacon-db + env_file: + - docker.env + restart: always + build: + dockerfile: ../ipld-eth-beacon-db/Dockerfile + context: ../ipld-eth-beacon-db + image: cerc/ipld-eth-beacon-db:local + healthcheck: + test: ["CMD", "nc", "-v", "localhost", "5432"] + interval: 5s + timeout: 3s + retries: 5 + volumes: + - vdb_db_eth-beacon_db:/var/lib/postgresql/data + ports: + - "5432" + command: ["postgres", "-c", "log_min_duration_statement=250"] + + ipld-eth-beacon-indexer: + hostname: ipld-eth-beacon-indexer + env_file: + - docker.env + restart: always + build: + dockerfile: ./Dockerfile + context: . + depends_on: + - ipld-eth-beacon-db + image: cerc/ipld-eth-beacon-indexer:local + +volumes: + vdb_db_eth-beacon_db: diff --git a/docker.env b/docker.env new file mode 100644 index 0000000..c2763b0 --- /dev/null +++ b/docker.env @@ -0,0 +1,28 @@ +POSTGRES_HOST=ipld-eth-beacon-db +POSTGRES_PASSWORD=CHANGEME +POSTGRES_PORT=5432 +POSTGRES_USER=ethbeacondb +POSTGRES_DB=ethbeacondb + +LIGHTHOUSE_HOST=host.docker.internal +LIGHTHOUSE_PORT=5052 +LIGHTHOUSE_PROTOCOL=http + +CAPTURE_MODE=head +LOG_LEVEL=debug + +BC_MAX_HISTORIC_PROCESS_WORKER=2 +BC_UNIQUE_NODE_IDENTIFIER=100 +BC_CHECK_DB=true +BC_BEACON_STATE_PROCESSING_ENABLED=false +BC_BEACON_BLOCK_PROCESSING_ENABLED=true +BC_MINIMUM_SLOT=4700013 + +KG_INCREMENT=10000 +KG_PROCESS_KNOWN_GAPS_ENABLED=true +KG_MAX_KNOWN_GAPS_WORKER=2 +KG_MINIMUM_SLOT=4700013 + +PROM_HOST=host.docker.internal +PROM_PORT=9000 +PROM_METRICS_ENABLED=false diff --git a/entrypoint.sh b/entrypoint.sh index 5cc37db..e808500 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,6 +3,8 @@ sleep 10 echo "Starting ipld-eth-beacon-indexer" +cat /root/ipld-eth-beacon-config-docker.json | envsubst > /root/ipld-eth-beacon-config.json + echo /root/ipld-eth-beacon-indexer capture ${CAPTURE_MODE} --config /root/ipld-eth-beacon-config.json > /root/ipld-eth-beacon-indexer.output if [ ${CAPTURE_MODE} == "boot" ]; then @@ -14,9 +16,10 @@ if [ ${CAPTURE_MODE} == "boot" ]; then else echo "ipld-eth-beacon-indexer boot succeeded" fi - echo $rv > /root/HEALTH - echo $rv - cat /root/ipld-eth-beacon-indexer.output + + echo $rv > /root/HEALTH + echo $rv + cat /root/ipld-eth-beacon-indexer.output tail -f /dev/null else diff --git a/ipld-eth-beacon-config-docker.json b/ipld-eth-beacon-config-docker.json new file mode 100644 index 0000000..2a12897 --- /dev/null +++ b/ipld-eth-beacon-config-docker.json @@ -0,0 +1,44 @@ +{ + "db": { + "address": "${POSTGRES_HOST}", + "password": "${POSTGRES_PASSWORD}", + "port": ${POSTGRES_PORT}, + "username": "${POSTGRES_USER}", + "name": "${POSTGRES_DB}", + "driver": "PGX" + }, + "bc": { + "address": "${LIGHTHOUSE_HOST}", + "port": ${LIGHTHOUSE_PORT}, + "type": "lighthouse", + "bootRetryInterval": 30, + "bootMaxRetry": 5, + "maxHistoricProcessWorker": ${BC_MAX_HISTORIC_PROCESS_WORKER}, + "connectionProtocol": "${LIGHTHOUSE_PROTOCOL}", + "uniqueNodeIdentifier": ${BC_UNIQUE_NODE_IDENTIFIER}, + "checkDb": ${BC_CHECK_DB}, + "performBeaconStateProcessing": ${BC_BEACON_STATE_PROCESSING_ENABLED}, + "performBeaconBlockProcessing": ${BC_BEACON_BLOCK_PROCESSING_ENABLED}, + "minimumSlot": ${BC_MINIMUM_SLOT} + }, + "t": { + "skipSync": true + }, + "log": { + "level": "${LOG_LEVEL}", + "output": true, + "file": "./ipld-eth-beacon-indexer.log", + "format": "json" + }, + "kg": { + "increment": ${KG_INCREMENT}, + "processKnownGaps": ${KG_PROCESS_KNOWN_GAPS_ENABLED}, + "maxKnownGapsWorker": ${KG_MAX_KNOWN_GAPS_WORKER}, + "minimumSlot": ${KG_MINIMUM_SLOT} + }, + "pm": { + "address": "${PROM_HOST}", + "port": ${PROM_PORT}, + "metrics": ${PROM_METRICS_ENABLED} + } +} diff --git a/ipld-eth-beacon-config.json b/ipld-eth-beacon-config.json deleted file mode 100644 index 7a22376..0000000 --- a/ipld-eth-beacon-config.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "db": { - "address": "localhost", - "password": "password", - "port": 5432, - "username": "vdbm", - "name": "vulcanize_db", - "driver": "PGX" - }, - "bc": { - "address": "localhost", - "port": 5052, - "type": "lighthouse", - "bootRetryInterval": 30, - "bootMaxRetry": 5, - "maxHistoricProcessWorker": 2, - "connectionProtocol": "http", - "uniqueNodeIdentifier": 100, - "checkDb": true, - "performBeaconStateProcessing": false, - "performBeaconBlockProcessing": true, - "minimumSlot": 4700013 - }, - "t": { - "skipSync": true - }, - "log": { - "level": "debug", - "output": true, - "file": "./ipld-eth-beacon-indexer.log", - "format": "json" - }, - "kg": { - "increment": 10000, - "processKnownGaps": true, - "maxKnownGapsWorker": 2, - "minimumSlot": 4700013 - }, - "pm": { - "address": "localhost", - "port": 9000, - "metrics": true - } -}