From 03c17f7df95753231f51759a25e43aa1007232a0 Mon Sep 17 00:00:00 2001 From: Ramon Tayag Date: Wed, 28 Mar 2018 08:57:11 +0800 Subject: [PATCH 1/2] `docker-compose up` and `docker build` work again VERSION defaults to 3.1.1 if not specified. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 72aa8ba..e341af9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM python:3.6-alpine ARG BUILD_DATE ARG VCS_REF -ARG VERSION +ARG VERSION=3.1.1 LABEL maintainer="oc@co.ru" \ org.label-schema.build-date=$BUILD_DATE \ org.label-schema.name="Electrum wallet" \ From a54654f45dd287d7a9a6554817e0a2d3f4bc8fb9 Mon Sep 17 00:00:00 2001 From: Ramon Tayag Date: Sat, 20 Jan 2018 20:43:07 +0800 Subject: [PATCH 2/2] Restore from ELECTRUM_MASTER_PRIVATE_KEY or ELECTRUM_MASTER_PUBLIC_KEY --- README.md | 4 ++++ docker-compose.yml | 2 ++ docker-entrypoint.sh | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/README.md b/README.md index 6577413..663e986 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,10 @@ curl --data-binary '{"id":"1","method":"listaddresses"}' http://electrum:electru Always link electrum daemon to containers or bind to localhost directly and not expose 7000 port for security reasons. +### 12 Factor + +You may also restore the wallet from a Master Private Key or Master Public Key by setting `ELECTRUM_MASTER_PRIVATE_KEY` or `ELECTRUM_MASTER_PUBLIC_KEY` env vars. This is useful in a setup like Kubernetes. If a wallet already exists, the master private key or the master public key will not be restored. + ## API * [Electrum protocol specs](http://docs.electrum.org/en/latest/protocol.html) diff --git a/docker-compose.yml b/docker-compose.yml index f7fc032..d151f81 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,3 +7,5 @@ services: environment: ELECTRUM_USER: electrum ELECTRUM_PASSWORD: changeme + ELECTRUM_MASTER_PRIVATE_KEY: xprv9s21ZrQH143K2qhNXjGPHr6Rdz3h2N5dnt4sFspFnDqP8rPCXi5YPHq6hqQ2jSJb6XM4qwbfwMqxP5qsFRFRBKMPnE3WiAhFsBkVcMv2rYX + ELECTRUM_MASTER_PUBLIC_KEY: xpub661MyMwAqRbcFKmqdkoPez3AC1tBRpoVA6zU4GDsLZNN1eiM5FPnw69aZ6NbpahyLMsKeyjf2eqS64xSqYfsj9YWFWUpKtzbXmkLiAsRyCF diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 329ec97..f77cb2e 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -15,6 +15,33 @@ electrum setconfig rpcport 7000 # Run application electrum daemon start +echo "checking status" +electrum daemon status +echo "Done" + +# Restore from keys if available +if [ -n "$ELECTRUM_MASTER_PRIVATE_KEY" ]; +then + echo "Restoring and loading wallet from Master Private Key" + { + # && - do not stop script if command fails + echo | electrum restore $ELECTRUM_MASTER_PRIVATE_KEY + } || { # catch + echo "Wallet already exists; skipping..." + } + electrum daemon load_wallet +elif [ -n "$ELECTRUM_MASTER_PUBLIC_KEY" ]; +then + echo "Restoring and loading wallet from Master Public Key" + { + # && - do not stop script if command fails + electrum restore $ELECTRUM_MASTER_PUBLIC_KEY + } || { + echo "Wallet already exists; skipping..." + } + electrum daemon load_wallet +fi + # Wait forever while true; do tail -f /dev/null & wait ${!}