From 2e088a99134f5eed4101805e083e3af3186f8ffa Mon Sep 17 00:00:00 2001 From: Kerem Kazan Date: Fri, 31 May 2024 17:05:02 -0400 Subject: [PATCH] dockerfile updates for archive node (#68) --- core/Dockerfile | 8 ++++++-- core/archive_node.supervisord.conf | 18 ++++++++++++++++++ core/docker-compose.yml | 3 ++- ...rvisord.conf => full_node.supervisord.conf} | 0 core/node/config/config.go | 6 +++--- core/node/default_config.yaml | 10 ++++++++++ core/node/rpc/archiver_test.go | 6 +++--- core/run.sh | 16 ++++++++++++++++ 8 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 core/archive_node.supervisord.conf rename core/{supervisord.conf => full_node.supervisord.conf} (100%) create mode 100755 core/run.sh diff --git a/core/Dockerfile b/core/Dockerfile index 29a629b60..a8fec70cd 100644 --- a/core/Dockerfile +++ b/core/Dockerfile @@ -9,6 +9,8 @@ ARG VER_VERSION=version_unset ARG VER_BRANCH=branch_unset ARG VER_COMMIT=commit_unset +ARG RUN_MODE=full + # Prepare build environment WORKDIR /build COPY node node @@ -39,7 +41,9 @@ LABEL org.opencontainers.image.title="River Node" \ RUN apk add --no-cache libcap supervisor && \ adduser -D riveruser -COPY supervisord.conf /etc/supervisord.conf +COPY run.sh /etc/run.sh +COPY full_node.supervisord.conf /etc/full_node.supervisord.conf +COPY archive_node.supervisord.conf /etc/archive_node.supervisord.conf COPY --from=builder /bin/stream_node /usr/bin/stream_node COPY --from=builder /bin/xchain_node /usr/bin/xchain_node @@ -66,4 +70,4 @@ ARG DD_GIT_REPOSITORY_URL="https://github.com/river-build/river" ENV DD_GIT_REPOSITORY_URL=${DD_GIT_REPOSITORY_URL} \ DD_GIT_COMMIT_SHA=${GIT_SHA} -CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] +CMD ["sh", "/etc/run.sh"] diff --git a/core/archive_node.supervisord.conf b/core/archive_node.supervisord.conf new file mode 100644 index 000000000..95a3f6772 --- /dev/null +++ b/core/archive_node.supervisord.conf @@ -0,0 +1,18 @@ +[supervisord] +logfile=/riveruser/supervisord/logs/supervisord.log ; (main log file;default $CWD/supervisord.log) +pidfile=/riveruser/supervisord/logs/supervisord.pid +nodaemon=true +loglevel=info +logfile=/dev/stdout +logfile_maxbytes=0 + +[program:archive_node] +command=/usr/bin/stream_node archive +directory=/riveruser/stream_node +autostart=true +autorestart=false +user=riveruser +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 \ No newline at end of file diff --git a/core/docker-compose.yml b/core/docker-compose.yml index 9348f8724..e55ef3c8e 100644 --- a/core/docker-compose.yml +++ b/core/docker-compose.yml @@ -14,6 +14,8 @@ services: - DATABASE__PASSWORD=postgres - DATABASE__EXTRA=?sslmode=disable&pool_max_conns=1000 - DATABASE__HOST=host.docker.internal + - RUN_MODE=archive + - ARCHIVE__ARCHIVEID=1 - DATABASE__PORT=5433 - LOG__FORMAT=json - LOG__NOCOLOR=true @@ -28,7 +30,6 @@ services: - USEBLOCKCHAINSTREAMREGISTRY=true - BASECHAIN__NETWORKURL=http://host.docker.internal:8545 - RIVERCHAIN__NETWORKURL=http://host.docker.internal:8546 - - WALLETPRIVATEKEY=51e02cbb807a535b05ae02f15cc3cbf73950e61d6dde55b3a77ad2be8815147c - ARCHITECTCONTRACT__ADDRESS=0x2552FcE4D398492E4fd063e6aA77186e5c6d0EF1 - REGISTRYCONTRACT__ADDRESS=0x531Faa70a60e151d20395E0E4ce9A32FB767Ca00 - ENTITLEMENT_CONTRACT__ADDRESS=0x2bdCC0de6bE1f7D2ee689a0342D76F52E8EFABa3 diff --git a/core/supervisord.conf b/core/full_node.supervisord.conf similarity index 100% rename from core/supervisord.conf rename to core/full_node.supervisord.conf diff --git a/core/node/config/config.go b/core/node/config/config.go index 10f020a95..86f0c9c0f 100644 --- a/core/node/config/config.go +++ b/core/node/config/config.go @@ -221,7 +221,7 @@ type ArchiveConfig struct { Filter FilterConfig // Number of miniblocks to read at once from the remote node. - ReadMiniblcocksSize uint64 + ReadMiniblocksSize uint64 DisablePrintStats bool PrintStatsPeriod time.Duration // If 0, default to 1 minute. @@ -250,10 +250,10 @@ type MetricsConfig struct { } func (ac *ArchiveConfig) GetReadMiniblocksSize() uint64 { - if ac.ReadMiniblcocksSize <= 0 { + if ac.ReadMiniblocksSize <= 0 { return 100 } - return ac.ReadMiniblcocksSize + return ac.ReadMiniblocksSize } func (ac *ArchiveConfig) GetPrintStatsPeriod() time.Duration { diff --git a/core/node/default_config.yaml b/core/node/default_config.yaml index 2a9a0f136..5ae5b22dd 100644 --- a/core/node/default_config.yaml +++ b/core/node/default_config.yaml @@ -123,4 +123,14 @@ test_contract: address: '' version: '3' +archive: + archiveId: '' + # filter: '' + # readMiniblocksSize: '' + # disablePrintStats: '' + printStatsPeriod: '10s' + # taskQueueSize: '' + # workerPoolSize: '' + # streamsContractCallPageSize: '' + enableDebugEndpoints: false diff --git a/core/node/rpc/archiver_test.go b/core/node/rpc/archiver_test.go index dd43623ff..e685e75fb 100644 --- a/core/node/rpc/archiver_test.go +++ b/core/node/rpc/archiver_test.go @@ -215,7 +215,7 @@ func TestArchiveOneStream(t *testing.T) { archiveCfg := tester.getConfig() archiveCfg.Archive.ArchiveId = "arch" + GenShortNanoid() - archiveCfg.Archive.ReadMiniblcocksSize = 3 + archiveCfg.Archive.ReadMiniblocksSize = 3 chainMonitor := tester.btc.ChainMonitor bc := tester.btc.NewWalletAndBlockchain(ctx) @@ -355,7 +355,7 @@ func TestArchive100StreamsWithData(t *testing.T) { archiveCfg := tester.getConfig() archiveCfg.Archive.ArchiveId = "arch" + GenShortNanoid() - archiveCfg.Archive.ReadMiniblcocksSize = 3 + archiveCfg.Archive.ReadMiniblocksSize = 3 listener, err := net.Listen("tcp", "localhost:0") require.NoError(err) @@ -403,7 +403,7 @@ func TestArchiveContinuous(t *testing.T) { archiveCfg := tester.getConfig() archiveCfg.Archive.ArchiveId = "arch" + GenShortNanoid() - archiveCfg.Archive.ReadMiniblcocksSize = 3 + archiveCfg.Archive.ReadMiniblocksSize = 3 listener, err := net.Listen("tcp", "localhost:0") require.NoError(err) diff --git a/core/run.sh b/core/run.sh new file mode 100755 index 000000000..9129a2323 --- /dev/null +++ b/core/run.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -euo pipefail + +if [ -z "$RUN_MODE" ]; then + echo "RUN_MODE is not set" + exit 1 +elif [ "$RUN_MODE" == "full" ]; then + echo "Running full node" + exec /usr/bin/supervisord -c /etc/full_node.supervisord.conf +elif [ "$RUN_MODE" == "archive" ]; then + echo "Running archive node" + exec /usr/bin/supervisord -c /etc/archive_node.supervisord.conf +else + echo "Unknown RUN_MODE: $RUN_MODE" + exit 1 +fi