-
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
Open
tomasvanagas
wants to merge
3
commits into
spesmilo:master
Choose a base branch
from
kaunofakultetas:PR_Dockerfile
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
SomberNight marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # 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 .` | ||
|
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` | ||
| # To clean shutdown, send TERM signal to the running container eg.: | ||
| # `docker kill --signal="TERM" CONTAINER_ID` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
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.
note: my local Dockerfile has stuff like this:
Point being, you don't need a git clone even for running HEAD.