From d62fa1d945820409313a388590c6998fb2f2eb1f Mon Sep 17 00:00:00 2001 From: urvisavla Date: Fri, 14 Jun 2024 14:14:39 -0700 Subject: [PATCH] exp/services/ledgerexporter: Streamline docker setup (#5348) --- exp/services/ledgerexporter/Makefile | 8 ++-- exp/services/ledgerexporter/docker/Dockerfile | 7 +--- .../ledgerexporter/docker/config.test.toml | 13 ++++++ exp/services/ledgerexporter/docker/start | 42 ------------------- 4 files changed, 18 insertions(+), 52 deletions(-) create mode 100644 exp/services/ledgerexporter/docker/config.test.toml delete mode 100644 exp/services/ledgerexporter/docker/start diff --git a/exp/services/ledgerexporter/Makefile b/exp/services/ledgerexporter/Makefile index 10bf16e9dd..971fc3eb25 100644 --- a/exp/services/ledgerexporter/Makefile +++ b/exp/services/ledgerexporter/Makefile @@ -33,12 +33,10 @@ docker-test: docker-clean # Run the ledger-exporter $(SUDO) docker run --platform linux/amd64 -t --network test-network\ - -e NETWORK=pubnet \ - -e ARCHIVE_TARGET=exporter-test/test-subpath \ - -e START=1000 \ - -e END=2000 \ + -v ${PWD}/exp/services/ledgerexporter/docker/config.test.toml:/config.toml \ -e STORAGE_EMULATOR_HOST=http://fake-gcs-server:4443 \ - $(DOCKER_IMAGE):$(VERSION) + $(DOCKER_IMAGE):$(VERSION) \ + scan-and-fill --start 1000 --end 2000 $(MAKE) docker-clean diff --git a/exp/services/ledgerexporter/docker/Dockerfile b/exp/services/ledgerexporter/docker/Dockerfile index 59e57030f3..7144800d87 100644 --- a/exp/services/ledgerexporter/docker/Dockerfile +++ b/exp/services/ledgerexporter/docker/Dockerfile @@ -26,12 +26,9 @@ RUN echo "deb https://apt.stellar.org focal unstable" >/etc/apt/sources.list.d/S RUN apt-get update && apt-get install -y stellar-core=${STELLAR_CORE_VERSION} RUN apt-get clean -COPY exp/services/ledgerexporter/docker/start / - -RUN ["chmod", "+x", "/start"] - COPY --from=builder /go/bin/ledgerexporter /usr/bin/ledgerexporter -ENTRYPOINT ["/start"] +ENTRYPOINT ["/usr/bin/ledgerexporter"] +CMD ["--help"] diff --git a/exp/services/ledgerexporter/docker/config.test.toml b/exp/services/ledgerexporter/docker/config.test.toml new file mode 100644 index 0000000000..c5c4519f0b --- /dev/null +++ b/exp/services/ledgerexporter/docker/config.test.toml @@ -0,0 +1,13 @@ +[datastore_config] +type = "GCS" + +[datastore_config.params] +destination_bucket_path = "exporter-test/ledgers/testnet" + +[datastore_config.schema] +ledgers_per_file = 1 +files_per_partition = 64000 + +[stellar_core_config] + network = "testnet" + diff --git a/exp/services/ledgerexporter/docker/start b/exp/services/ledgerexporter/docker/start deleted file mode 100644 index 3b61c74eee..0000000000 --- a/exp/services/ledgerexporter/docker/start +++ /dev/null @@ -1,42 +0,0 @@ -#! /usr/bin/env bash -set -e - -# Validation -if [ -z "$ARCHIVE_TARGET" ]; then - echo "error: undefined ARCHIVE_TARGET env variable" - exit 1 -fi - -if [ -z "$NETWORK" ]; then - echo "error: undefined NETWORK env variable" - exit 1 -fi - -ledgers_per_file="${LEDGERS_PER_FILE:-1}" -files_per_partition="${FILES_PER_PARTITION:-64000}" - -# Generate TOML configuration -cat < config.toml - -[datastore_config] -type = "GCS" - -[datastore_config.params] -destination_bucket_path = "${ARCHIVE_TARGET}/${NETWORK}" - -[datastore_config.schema] - ledgers_per_file = $ledgers_per_file - files_per_partition = $files_per_partition - -[stellar_core_config] - network = "${NETWORK}" -EOF - -# Check if START or END variables are set -if [[ -n "$START" || -n "$END" ]]; then - echo "START: $START END: $END" - /usr/bin/ledgerexporter scan-and-fill --config-file config.toml --start $START --end $END -else - echo "Error: No ledger range provided." - exit 1 -fi