From 3265446bd9a1fba5de07121498e2bf48c4bf09a0 Mon Sep 17 00:00:00 2001 From: squidbear <379651+czarly@users.noreply.github.com> Date: Tue, 25 Mar 2025 09:08:30 +0100 Subject: [PATCH] change the current sonic build slightly --- sonic/Dockerfile | 12 +++--------- sonic/entrypoint.sh | 26 ++++++++++++-------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/sonic/Dockerfile b/sonic/Dockerfile index 197d31d4..a79a46c2 100644 --- a/sonic/Dockerfile +++ b/sonic/Dockerfile @@ -1,10 +1,3 @@ -# Running Sonic in Docker is Experimental - not recommended for production use! - -# Example of usage: -# docker build -t sonic . -# docker run --name sonic1 --entrypoint sonictool sonic --datadir=/var/sonic genesis fake 1 -# docker run --volumes-from sonic1 -p 5050:5050 -p 5050:5050/udp -p 18545:18545 sonic --fakenet 1/1 --http --http.addr=0.0.0.0 - FROM golang:1.22 as builder ARG VERSION @@ -24,10 +17,11 @@ FROM golang:1.22 COPY --from=builder /go/sonic/build/sonicd /usr/local/bin/ COPY --from=builder /go/sonic/build/sonictool /usr/local/bin/ -COPY ./entrypoint.sh /entrypoint.sh +COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh +RUM chmod +x /usr/local/bin/entrypoint.sh EXPOSE 18545 18546 5050 5050/udp VOLUME /var/sonic -ENTRYPOINT ["bash", "/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] \ No newline at end of file diff --git a/sonic/entrypoint.sh b/sonic/entrypoint.sh index 3c3625a3..be00824a 100644 --- a/sonic/entrypoint.sh +++ b/sonic/entrypoint.sh @@ -1,25 +1,23 @@ #!/bin/bash -if [ ! -f /var/sonic/initialized ]; then +datadir=/var/sonic + +if [ ! -f "$datadir/initialized" ]; then echo "Initializing Sonic..." - # Add your initialization commands here - # Example: - # mkdir -p /var/sonic/data - # touch /var/sonic/config.json - - wget https://genesis.soniclabs.com/sonic-mainnet/genesis/sonic.g - GOMEMLIMIT=50GiB sonictool --datadir /var/sonic --cache 12000 genesis sonic.g - rm sonic.g + url="${GENESIS:-https://genesis.soniclabs.com/sonic-mainnet/genesis/sonic.g}" + filename=$(basename "$url") - # Create the file to mark initialization - touch /var/sonic/initialized + wget -P "$datadir" "$url" + + GOMEMLIMIT="${CACHE_GB}GiB" sonictool --datadir "$datadir" --cache "${CACHE_GB}000" genesis "$datadir/$filename" + rm "$datadir/$filename" + + touch "$datadir/initialized" echo "Initialization complete." else echo "Sonic is already initialized." fi -touch /var/sonic/initialized - -exec sonicd --datadir /var/sonic "$@" +exec sonicd --cache "${CACHE_GB}000" --datadir "$datadir" "$@"