diff --git a/contrib/Dockerfile b/contrib/Dockerfile index a7cea0a8f..b1841dd4a 100644 --- a/contrib/Dockerfile +++ b/contrib/Dockerfile @@ -1,48 +1,45 @@ -# example of Dockerfile that installs spesmilo electrumx 1.16.0 -# ENV variables can be overridden on the `docker run` command +FROM python:3.14.0-slim -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 leveldb 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 libleveldb-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 -FROM python:3.9.16-slim-bullseye +# Install from local source with rapidjson support +RUN pip install --upgrade pip \ + && pip install /electrumx[rapidjson] -# 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/* +# Data directory for electrumx +RUN mkdir -p /var/lib/electrumx +# Environment defaults ENV SERVICES="tcp://:50001" ENV COIN=Bitcoin +ENV NET=mainnet ENV DB_DIRECTORY=/var/lib/electrumx 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 -WORKDIR /usr/src/app -COPY --from=builder /usr/src/app . +CMD ["electrumx_server"] + + +# To build electrumx run the following command: +# `docker build -f Dockerfile -t electrumx ..` -VOLUME /var/lib/electrumx -RUN mkdir -p "$DB_DIRECTORY" && ulimit -n 1048576 +# 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` -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` +# To clean shutdown, send TERM signal to the running container eg.: +# `docker kill --signal="TERM" CONTAINER_ID`