-
Notifications
You must be signed in to change notification settings - Fork 411
Dockerfile rewrite for ElectrumX 1.18.0 #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,48 +1,35 @@ | ||
| # 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 \ | ||
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes the Dockerfile depend on the repository being available while the previous Dockerfile would fetch e-x from PyPI and work independently of the repository. What is your reasoning behind this change? I think its nice to have encapsulated Dockerfile so it doesn't depend on files being available on the host system.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: my local Dockerfile has stuff like this: Point being, you don't need a git clone even for running HEAD. |
||
|
|
||
| FROM python:3.9.16-slim-bullseye | ||
| # Install from local source with rapidjson support | ||
| RUN pip install --upgrade pip \ | ||
| && pip install "Cython<3.0" \ | ||
| && 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 /data | ||
|
|
||
| # 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 | ||
| 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 . | ||
|
|
||
| VOLUME /var/lib/electrumx | ||
|
|
||
| RUN mkdir -p "$DB_DIRECTORY" && ulimit -n 1048576 | ||
SomberNight marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| CMD ["/usr/src/app/venv/bin/python", "/usr/src/app/venv/bin/electrumx_server"] | ||
|
|
||
| # build it with eg.: `docker build -t electrumx .` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we keep these examples/docs in the Dockerfile? They seem useful. |
||
| # 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"] | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use Python 3.14? It would provide better performance and wouldn't need to be updated anytime soon again, making the Dockerfile more "future proof".