From e0533059a06ee50c70d4a7b7bbac3129d7929796 Mon Sep 17 00:00:00 2001 From: Jesse Schulman Date: Thu, 1 Aug 2024 13:29:00 -0700 Subject: [PATCH] Compress data dir to avoid sparse file bloating image, adding entrypoint.sh to extract data dir before launching nodeos --- Dockerfile | 4 +++- entrypoint.sh | 10 ++++++++++ setup_network.sh | 9 ++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 5da8977..a2fb646 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,5 +20,7 @@ COPY contracts /app/contracts RUN bash /app/setup_network.sh +COPY entrypoint.sh /app/entrypoint.sh -CMD ["nodeos", "--data-dir=/node/data-dir", "--config-dir=/node", "--enable-stale-production", "--genesis-json=/node/genesis.json"] +#CMD ["nodeos", "--data-dir=/node/data-dir", "--config-dir=/node", "--enable-stale-production", "--genesis-json=/node/genesis.json"] +CMD ["./entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..68baff8 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -ex + +cd /node + +tar -xvf data-dir.tar.gz +nodeos --data-dir=/node/data-dir --config-dir=/node --enable-stale-production --genesis-json=/node/genesis.json + +cd - diff --git a/setup_network.sh b/setup_network.sh index 3c7d58e..17e14d0 100644 --- a/setup_network.sh +++ b/setup_network.sh @@ -64,4 +64,11 @@ cd $OG_DIR sleep 5 kill $NODEOS_PID -sleep 10 \ No newline at end of file +sleep 10 + +# Compress the data directory using the -S (sparse) flag to reduce the size of the image +# It is extracted before starting nodeos in the entrypoint.sh script +cd /node +tar -cSvzf data-dir.tar.gz ./data-dir +rm -rf data-dir +cd $OG_DIR \ No newline at end of file