diff --git a/.gitignore b/.gitignore index cceb134da..9bc51c61d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ docs/_build .vscode/ .mypy_cache/ .idea/ +contrib/.env \ No newline at end of file diff --git a/contrib/Dockerfile b/contrib/Dockerfile index 11cbe3725..d7e92d938 100644 --- a/contrib/Dockerfile +++ b/contrib/Dockerfile @@ -40,9 +40,15 @@ VOLUME /var/lib/electrumx RUN mkdir -p "$DB_DIRECTORY" && ulimit -n 1048576 +STOPSIGNAL SIGINT + 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` +# `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` diff --git a/contrib/docker-compose.yml b/contrib/docker-compose.yml new file mode 100644 index 000000000..9ad5e995c --- /dev/null +++ b/contrib/docker-compose.yml @@ -0,0 +1,51 @@ +version: "3.7" + +services: + + electrumx: + container_name: electrumx + #define $UID, $GID in .env file the user to run docker and write in data folder + #user: "$UID:$GID" + environment: + ## create a copy of ./dot.env.sample in new .env file + ## references: ../docs/environment.rst + # + #CACHE_MB: 2000 + #COST_HARD_LIMIT: 10000 + #COST_SOFT_LIMIT: 1000 + #DAEMON_VERSION: + #DB_ENGINE: leveldb + #MAX_SEND: 1000000 + #MAX_SESSIONS: 30000 + #PEER_ANNOUNCE: + #REQUEST_TIMEOUT: 30 + #SERVICES: "tcp://:50001,ssl://:50002,wss://:50004,rpc://0.0.0.0:8000" + #SSL_CERTFILE: /etc/ssl/certs/electrumx.crt + #SSL_KEYFILE: /etc/ssl/private/electrumx.key + ALLOW_ROOT: true + COIN: Bitcoin + #define $USERPASS in .env file + #define $DAEMON_HOST .env file, use 172.17.0.1 if bitcoincore in the same machine of docker + DAEMON_URL: "http://$USERPASS@$DAEMON_HOST:8332/" + DB_DIRECTORY: /var/lib/electrumx + DB_ENGINE: leveldb + LOG_LEVEL: debug + PEER_DISCOVERY: 'off' + SERVICES: "tcp://:50001" + + build: + context: . + args: + VERSION: $VERSION + dockerfile: ./Dockerfile + image: electrumx:latest + restart: "no" + ports: + - "50001:50001" + - "50002:50002" + - "50004:50004" + - "8000:8000" + #volumes: + #define $DATA folder in .env file + #- $DATA:/var/lib/electrumx + #- ./ssl:/etc/ssl diff --git a/contrib/dot.env.sample b/contrib/dot.env.sample new file mode 100644 index 000000000..b9f4b8513 --- /dev/null +++ b/contrib/dot.env.sample @@ -0,0 +1,5 @@ +DATA=/data +UID=1000 +GID=1000 +DAEMON_HOST=172.17.0.1 +USERPASS=user:pass