From a63afc73e8ac24a08eb44dd9bc1917d006bc64aa Mon Sep 17 00:00:00 2001 From: Tomas Vanagas Date: Thu, 30 Oct 2025 12:16:21 +0200 Subject: [PATCH 1/3] Complete Dockerfile rewrite for ElectrumX 1.18.0 --- contrib/Dockerfile | 53 +++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/contrib/Dockerfile b/contrib/Dockerfile index a7cea0a8f..8d64a910f 100644 --- a/contrib/Dockerfile +++ b/contrib/Dockerfile @@ -1,31 +1,37 @@ -# example of Dockerfile that installs spesmilo electrumx 1.16.0 -# ENV variables can be overridden on the `docker run` command +FROM python:3.10.14-bullseye -FROM python:3.9.16-bullseye AS builder +WORKDIR /electrumx -WORKDIR /usr/src/app - -# Install the libs needed by rocksdb (including development headers) +# Install all dependencies (build + runtime) for rocksdb RUN apt-get update \ - && apt-get -y --no-install-recommends install \ - librocksdb-dev libsnappy-dev libbz2-dev libz-dev liblz4-dev \ + && apt-get install -y --no-install-recommends \ + build-essential \ + librocksdb-dev \ + libsnappy-dev \ + libbz2-dev \ + zlib1g-dev \ + liblz4-dev \ && rm -rf /var/lib/apt/lists/* -RUN python -m venv venv \ - && venv/bin/pip install --no-cache-dir e-x[rapidjson,rocksdb]==1.16.0 +# Copy the entire electrumx source tree +COPY . /electrumx +# Install from local source with rocksdb support +RUN pip install --upgrade pip \ + && pip install "Cython<3.0" \ + && pip install /electrumx[rapidjson,rocksdb] + +# Data directory for electrumx +RUN mkdir -p /data -FROM python:3.9.16-slim-bullseye -# Install the libs needed by rocksdb (no development headers or statics) -RUN apt-get update \ - && apt-get -y --no-install-recommends install \ - librocksdb6.11 libsnappy1v5 libbz2-1.0 zlib1g liblz4-1 \ - && rm -rf /var/lib/apt/lists/* + +# Environment defaults ENV SERVICES="tcp://:50001" ENV COIN=Bitcoin -ENV DB_DIRECTORY=/var/lib/electrumx +ENV NET=mainnet +ENV DB_DIRECTORY=/data ENV DAEMON_URL="http://username:password@hostname:port/" ENV ALLOW_ROOT=true ENV DB_ENGINE=rocksdb @@ -33,16 +39,5 @@ ENV MAX_SEND=10000000 ENV BANDWIDTH_UNIT_COST=50000 ENV CACHE_MB=2000 -WORKDIR /usr/src/app -COPY --from=builder /usr/src/app . - -VOLUME /var/lib/electrumx - -RUN mkdir -p "$DB_DIRECTORY" && ulimit -n 1048576 - -CMD ["/usr/src/app/venv/bin/python", "/usr/src/app/venv/bin/electrumx_server"] -# build it with eg.: `docker build -t electrumx .` -# run it with eg.: -# `docker run -d --net=host -v /home/electrumx/db/:/var/lib/electrumx -e DAEMON_URL="http://youruser:yourpass@localhost:8332" -e REPORT_SERVICES=tcp://example.com:50001 electrumx` -# for a clean shutdown, send TERM signal to the running container eg.: `docker kill --signal="TERM" CONTAINER_ID` +CMD ["electrumx_server"] \ No newline at end of file From eda82898cf34f329297438b610b5e23d5dcf9a37 Mon Sep 17 00:00:00 2001 From: Tomas Vanagas Date: Thu, 30 Oct 2025 12:32:19 +0200 Subject: [PATCH 2/3] Only leveldb left --- contrib/Dockerfile | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/contrib/Dockerfile b/contrib/Dockerfile index 8d64a910f..550ffc33d 100644 --- a/contrib/Dockerfile +++ b/contrib/Dockerfile @@ -6,27 +6,20 @@ WORKDIR /electrumx RUN apt-get update \ && apt-get install -y --no-install-recommends \ build-essential \ - librocksdb-dev \ - libsnappy-dev \ - libbz2-dev \ - zlib1g-dev \ - liblz4-dev \ + libleveldb-dev \ && rm -rf /var/lib/apt/lists/* # Copy the entire electrumx source tree COPY . /electrumx -# Install from local source with rocksdb support +# Install from local source with rapidjson support RUN pip install --upgrade pip \ && pip install "Cython<3.0" \ - && pip install /electrumx[rapidjson,rocksdb] + && pip install /electrumx[rapidjson] # Data directory for electrumx RUN mkdir -p /data - - - # Environment defaults ENV SERVICES="tcp://:50001" ENV COIN=Bitcoin @@ -34,10 +27,9 @@ ENV NET=mainnet ENV DB_DIRECTORY=/data ENV DAEMON_URL="http://username:password@hostname:port/" ENV ALLOW_ROOT=true -ENV DB_ENGINE=rocksdb +ENV DB_ENGINE=leveldb ENV MAX_SEND=10000000 ENV BANDWIDTH_UNIT_COST=50000 ENV CACHE_MB=2000 - CMD ["electrumx_server"] \ No newline at end of file From b6559f83f2d568351de63e29e4829b9fbfeb6ff5 Mon Sep 17 00:00:00 2001 From: Tomas Vanagas Date: Fri, 31 Oct 2025 12:27:27 +0200 Subject: [PATCH 3/3] Dockerfile changes based on review --- contrib/Dockerfile | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/contrib/Dockerfile b/contrib/Dockerfile index 550ffc33d..b1841dd4a 100644 --- a/contrib/Dockerfile +++ b/contrib/Dockerfile @@ -1,12 +1,11 @@ -FROM python:3.10.14-bullseye +FROM python:3.14.0-slim WORKDIR /electrumx -# Install all dependencies (build + runtime) for rocksdb +# Install all dependencies (build + runtime) for leveldb RUN apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential \ - libleveldb-dev \ + build-essential libleveldb-dev \ && rm -rf /var/lib/apt/lists/* # Copy the entire electrumx source tree @@ -14,17 +13,16 @@ COPY . /electrumx # Install from local source with rapidjson support RUN pip install --upgrade pip \ - && pip install "Cython<3.0" \ && pip install /electrumx[rapidjson] # Data directory for electrumx -RUN mkdir -p /data +RUN mkdir -p /var/lib/electrumx # Environment defaults ENV SERVICES="tcp://:50001" ENV COIN=Bitcoin ENV NET=mainnet -ENV DB_DIRECTORY=/data +ENV DB_DIRECTORY=/var/lib/electrumx ENV DAEMON_URL="http://username:password@hostname:port/" ENV ALLOW_ROOT=true ENV DB_ENGINE=leveldb @@ -32,4 +30,16 @@ ENV MAX_SEND=10000000 ENV BANDWIDTH_UNIT_COST=50000 ENV CACHE_MB=2000 -CMD ["electrumx_server"] \ No newline at end of file +CMD ["electrumx_server"] + + +# To build electrumx run the following command: +# `docker build -f Dockerfile -t electrumx ..` + + +# To run electrumx run the following command: +# `docker run -d --net=host -v /home/electrumx/db/:/var/lib/electrumx -e DAEMON_URL="http://youruser:yourpass@localhost:8332" -e REPORT_SERVICES=tcp://example.com:50001 electrumx` + + +# To clean shutdown, send TERM signal to the running container eg.: +# `docker kill --signal="TERM" CONTAINER_ID`