mirror of
https://github.com/basicswap/basicswap.git
synced 2025-01-03 09:19:26 +00:00
preparescript: Support production docker config.
This commit is contained in:
parent
398ef268a6
commit
2be16465fb
14 changed files with 206 additions and 58 deletions
|
@ -1,3 +1,3 @@
|
|||
name = "basicswap"
|
||||
|
||||
__version__ = "0.0.18"
|
||||
__version__ = "0.0.19"
|
||||
|
|
|
@ -729,6 +729,7 @@ class BasicSwap(BaseApp):
|
|||
if c == Coins.PART:
|
||||
self.coin_clients[c]['have_spent_index'] = ci.haveSpentIndex()
|
||||
|
||||
try:
|
||||
# Sanity checks
|
||||
rv = self.callcoinrpc(c, 'extkey')
|
||||
if 'result' in rv and 'No keys to list.' in rv['result']:
|
||||
|
@ -736,6 +737,9 @@ class BasicSwap(BaseApp):
|
|||
|
||||
if self.callcoinrpc(c, 'getstakinginfo')['enabled'] is not False:
|
||||
self.log.warning('%s staking is not disabled.', ci.coin_name())
|
||||
except Exception as e:
|
||||
self.log.error('Sanity checks failed: %s', str(e))
|
||||
|
||||
elif c == Coins.XMR:
|
||||
ci.ensureWalletExists()
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ from basicswap.rpc import (
|
|||
)
|
||||
from basicswap.basicswap import BasicSwap
|
||||
from basicswap.chainparams import Coins
|
||||
from basicswap.contrib.rpcauth import generate_salt, password_to_hmac
|
||||
from bin.basicswap_run import startDaemon, startXmrWalletDaemon
|
||||
|
||||
|
||||
|
@ -77,6 +78,14 @@ LTC_RPC_PORT = int(os.getenv('LTC_RPC_PORT', 19795))
|
|||
BTC_RPC_PORT = int(os.getenv('BTC_RPC_PORT', 19796))
|
||||
NMC_RPC_PORT = int(os.getenv('NMC_RPC_PORT', 19798))
|
||||
|
||||
PART_RPC_USER = os.getenv('PART_RPC_USER', '')
|
||||
PART_RPC_PWD = os.getenv('PART_RPC_PWD', '')
|
||||
BTC_RPC_USER = os.getenv('BTC_RPC_USER', '')
|
||||
BTC_RPC_PWD = os.getenv('BTC_RPC_PWD', '')
|
||||
LTC_RPC_USER = os.getenv('LTC_RPC_USER', '')
|
||||
LTC_RPC_PWD = os.getenv('LTC_RPC_PWD', '')
|
||||
|
||||
COINS_BIND_IP = os.getenv('COINS_BIND_IP', '127.0.0.1')
|
||||
|
||||
extract_core_overwrite = True
|
||||
|
||||
|
@ -328,18 +337,23 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic):
|
|||
fp.write('testnet=1\n')
|
||||
fp.write('data-dir={}\n'.format(data_dir))
|
||||
fp.write('rpc-bind-port={}\n'.format(core_settings['rpcport']))
|
||||
fp.write('rpc-bind-ip=127.0.0.1\n')
|
||||
fp.write('rpc-bind-ip={}\n'.format(COINS_BIND_IP))
|
||||
fp.write('zmq-rpc-bind-port={}\n'.format(core_settings['zmqport']))
|
||||
fp.write('zmq-rpc-bind-ip=127.0.0.1\n')
|
||||
fp.write('zmq-rpc-bind-ip={}\n'.format(COINS_BIND_IP))
|
||||
fp.write('prune-blockchain=1\n')
|
||||
|
||||
wallet_conf_path = os.path.join(data_dir, coin + '_wallet.conf')
|
||||
wallets_dir = core_settings.get('walletsdir', data_dir)
|
||||
if not os.path.exists(wallets_dir):
|
||||
os.makedirs(wallets_dir)
|
||||
|
||||
wallet_conf_path = os.path.join(wallets_dir, coin + '_wallet.conf')
|
||||
if os.path.exists(wallet_conf_path):
|
||||
exitWithError('{} exists'.format(wallet_conf_path))
|
||||
with open(wallet_conf_path, 'w') as fp:
|
||||
fp.write('daemon-address={}:{}\n'.format(core_settings['rpchost'], core_settings['rpcport']))
|
||||
fp.write('no-dns=1\n')
|
||||
fp.write('rpc-bind-port={}\n'.format(core_settings['walletrpcport']))
|
||||
fp.write('rpc-bind-ip={}\n'.format(COINS_BIND_IP))
|
||||
fp.write('wallet-dir={}\n'.format(os.path.join(data_dir, 'wallets')))
|
||||
fp.write('log-file={}\n'.format(os.path.join(data_dir, 'wallet.log')))
|
||||
fp.write('shared-ringdb-dir={}\n'.format(os.path.join(data_dir, 'shared-ringdb')))
|
||||
|
@ -358,25 +372,36 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic):
|
|||
else:
|
||||
logger.warning('Unknown chain %s', chain)
|
||||
|
||||
if COINS_BIND_IP != '127.0.0.1':
|
||||
fp.write('rpcallowip=127.0.0.1\n')
|
||||
fp.write('rpcallowip=172.0.0.0/8\n') # Allow 172.x.x.x, range used by docker
|
||||
fp.write('rpcbind={}\n'.format(COINS_BIND_IP))
|
||||
|
||||
fp.write('rpcport={}\n'.format(core_settings['rpcport']))
|
||||
fp.write('printtoconsole=0\n')
|
||||
fp.write('daemon=0\n')
|
||||
fp.write('wallet=wallet.dat\n')
|
||||
|
||||
salt = generate_salt(16)
|
||||
if coin == 'particl':
|
||||
fp.write('debugexclude=libevent\n')
|
||||
fp.write('zmqpubsmsg=tcp://127.0.0.1:{}\n'.format(settings['zmqport']))
|
||||
fp.write('zmqpubsmsg=tcp://{}:{}\n'.format(COINS_BIND_IP, settings['zmqport']))
|
||||
fp.write('spentindex=1\n')
|
||||
fp.write('txindex=1\n')
|
||||
fp.write('staking=0\n')
|
||||
|
||||
if PART_RPC_USER != '':
|
||||
fp.write('rpcauth={}:{}${}\n'.format(PART_RPC_USER, salt, password_to_hmac(salt, PART_RPC_PWD)))
|
||||
if particl_mnemonic == 'none':
|
||||
fp.write('createdefaultmasterkey=1')
|
||||
elif coin == 'litecoin':
|
||||
fp.write('prune=2000\n')
|
||||
if LTC_RPC_USER != '':
|
||||
fp.write('rpcauth={}:{}${}\n'.format(LTC_RPC_USER, salt, password_to_hmac(salt, LTC_RPC_PWD)))
|
||||
elif coin == 'bitcoin':
|
||||
fp.write('prune=2000\n')
|
||||
fp.write('fallbackfee=0.0002\n')
|
||||
if BTC_RPC_USER != '':
|
||||
fp.write('rpcauth={}:{}${}\n'.format(BTC_RPC_USER, salt, password_to_hmac(salt, BTC_RPC_PWD)))
|
||||
elif coin == 'namecoin':
|
||||
fp.write('prune=2000\n')
|
||||
else:
|
||||
|
@ -627,6 +652,18 @@ def main():
|
|||
}
|
||||
}
|
||||
|
||||
if PART_RPC_USER != '':
|
||||
chainclients['particl']['rpcuser'] = PART_RPC_USER
|
||||
chainclients['particl']['rpcpassword'] = PART_RPC_PWD
|
||||
if LTC_RPC_USER != '':
|
||||
chainclients['litecoin']['rpcuser'] = LTC_RPC_USER
|
||||
chainclients['litecoin']['rpcpassword'] = LTC_RPC_PWD
|
||||
if BTC_RPC_USER != '':
|
||||
chainclients['bitcoin']['rpcuser'] = BTC_RPC_USER
|
||||
chainclients['bitcoin']['rpcpassword'] = BTC_RPC_PWD
|
||||
|
||||
chainclients['monero']['walletsdir'] = os.getenv('XMR_WALLETS_DIR', chainclients['monero']['datadir'])
|
||||
|
||||
if disable_coin != '':
|
||||
logger.info('Disabling coin: %s', disable_coin)
|
||||
if not os.path.exists(config_path):
|
||||
|
|
|
@ -1,2 +1,22 @@
|
|||
HTML_PORT=127.0.0.1:12700:12700
|
||||
TZ=UTC
|
||||
DATA_PATH=/mnt/hdd50/docker2
|
||||
|
||||
PART_RPC_HOST=particl_core
|
||||
LTC_RPC_HOST=litecoin_core
|
||||
BTC_RPC_HOST=bitcoin_core
|
||||
|
||||
PART_RPC_USER=particl_user
|
||||
PART_RPC_PWD=particl_pwd
|
||||
BTC_RPC_USER=bitcoin_user
|
||||
BTC_RPC_PWD=bitcoin_pwd
|
||||
LTC_RPC_USER=litecoin_user
|
||||
LTC_RPC_PWD=litecoin_pwd
|
||||
|
||||
PART_DATA_DIR=/data/particl
|
||||
LTC_DATA_DIR=/data/litecoin
|
||||
BTC_DATA_DIR=/data/bitcoin
|
||||
XMR_DATA_DIR=/data/monero_daemon
|
||||
XMR_WALLETS_DIR=/data/monero_wallet
|
||||
|
||||
COINS_BIND_IP=0.0.0.0
|
||||
|
|
1
docker/production/.gitignore
vendored
Normal file
1
docker/production/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.env
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
FROM i_swapclient as install_stage
|
||||
|
||||
RUN basicswap-prepare --preparebinonly --bindir=/coin_bin --withcoin=bitcoin --withoutcoins=particl
|
||||
RUN basicswap-prepare --preparebinonly --bindir=/coin_bin --withcoin=bitcoin --withoutcoins=particl && \
|
||||
find /coin_bin -name *.tar.gz -delete
|
||||
|
||||
FROM debian:buster-slim
|
||||
COPY --from=install_stage /coin_bin .
|
||||
|
@ -23,4 +24,4 @@ COPY entrypoint.sh /entrypoint.sh
|
|||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
EXPOSE 8332 8333 18332 18333 18443 18444
|
||||
CMD ["bitcoind"]
|
||||
CMD ["/bitcoin/bitcoind", "--datadir=/data"]
|
||||
|
|
|
@ -8,9 +8,9 @@ services:
|
|||
dockerfile: Dockerfile
|
||||
container_name: particl_core
|
||||
volumes:
|
||||
- /var/swapdata/particl:/data
|
||||
ports:
|
||||
- "51738:51738"
|
||||
- ${DATA_PATH}/particl:/data
|
||||
#ports:
|
||||
# - "51738:51738"
|
||||
expose:
|
||||
- 51735
|
||||
logging:
|
||||
|
@ -19,18 +19,32 @@ services:
|
|||
max-size: "10m"
|
||||
max-file: "3"
|
||||
restart: unless-stopped
|
||||
bitcoin_core:
|
||||
image: i_bitcoin
|
||||
#bitcoin_core:
|
||||
#image: i_bitcoin
|
||||
#build:
|
||||
#context: bitcoin
|
||||
#dockerfile: Dockerfile
|
||||
#container_name: bitcoin_core
|
||||
#volumes:
|
||||
#- ${DATA_PATH}/bitcoin:/data
|
||||
##ports:
|
||||
## - "8333:8333"
|
||||
#expose:
|
||||
#- 8332
|
||||
#logging:
|
||||
#driver: "json-file"
|
||||
#options:
|
||||
#max-size: "10m"
|
||||
#max-file: "3"
|
||||
#restart: unless-stopped
|
||||
litecoin_core:
|
||||
image: i_litecoin
|
||||
build:
|
||||
context: bitcoin
|
||||
context: litecoin
|
||||
dockerfile: Dockerfile
|
||||
container_name: bitcoin_core
|
||||
container_name: litecoin_core
|
||||
volumes:
|
||||
- /var/swapdata/bitcoin:/data
|
||||
ports:
|
||||
- "8333:8333"
|
||||
expose:
|
||||
- 8332
|
||||
- ${DATA_PATH}/litecoin:/data
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
|
@ -44,7 +58,7 @@ services:
|
|||
#dockerfile: Dockerfile
|
||||
#container_name: monero_daemon
|
||||
#volumes:
|
||||
#- /var/swapdata/monero_daemon:/data
|
||||
#- ${DATA_PATH}/monero_daemon:/data
|
||||
#ports:
|
||||
#- "18080:18080"
|
||||
#expose:
|
||||
|
@ -55,22 +69,22 @@ services:
|
|||
#max-size: "10m"
|
||||
#max-file: "3"
|
||||
#restart: unless-stopped
|
||||
monero_wallet:
|
||||
image: i_monero_wallet
|
||||
build:
|
||||
context: monero_wallet
|
||||
dockerfile: Dockerfile
|
||||
container_name: monero_wallet
|
||||
volumes:
|
||||
- /var/swapdata/monero_wallet:/data
|
||||
expose:
|
||||
- 8332
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
restart: unless-stopped
|
||||
#monero_wallet:
|
||||
#image: i_monero_wallet
|
||||
#build:
|
||||
#context: monero_wallet
|
||||
#dockerfile: Dockerfile
|
||||
#container_name: monero_wallet
|
||||
#volumes:
|
||||
#- ${DATA_PATH}/monero_wallet:/data
|
||||
#expose:
|
||||
#- 8332
|
||||
#logging:
|
||||
#driver: "json-file"
|
||||
#options:
|
||||
#max-size: "10m"
|
||||
#max-file: "3"
|
||||
#restart: unless-stopped
|
||||
swapclient:
|
||||
image: i_swapclient
|
||||
build:
|
||||
|
@ -78,7 +92,7 @@ services:
|
|||
dockerfile: Dockerfile
|
||||
container_name: swapclient
|
||||
volumes:
|
||||
- /var/swapdata/swapclient:/data
|
||||
- ${DATA_PATH}/swapclient:/data
|
||||
ports:
|
||||
- "${HTML_PORT}" # Expose only to localhost, see .env
|
||||
environment:
|
||||
|
@ -91,6 +105,50 @@ services:
|
|||
depends_on:
|
||||
- particl_core
|
||||
restart: unless-stopped
|
||||
swapprepare:
|
||||
image: i_swapclient
|
||||
build:
|
||||
context: swapclient
|
||||
dockerfile: Dockerfile
|
||||
container_name: swapprepare
|
||||
volumes:
|
||||
- ${DATA_PATH}/swapclient:/data/swapclient
|
||||
- ${DATA_PATH}/monero_daemon:/data/monero_daemon
|
||||
- ${DATA_PATH}/monero_wallet:/data/monero_wallet
|
||||
- ${DATA_PATH}/particl:/data/particl
|
||||
- ${DATA_PATH}/bitcoin:/data/bitcoin
|
||||
- ${DATA_PATH}/litecoin:/data/litecoin
|
||||
environment:
|
||||
- TZ
|
||||
- PART_RPC_HOST
|
||||
- LTC_RPC_HOST
|
||||
- BTC_RPC_HOST
|
||||
- PART_RPC_PORT
|
||||
- LTC_RPC_PORT
|
||||
- BTC_RPC_PORT
|
||||
- XMR_RPC_HOST
|
||||
- BASE_XMR_RPC_PORT
|
||||
- BASE_XMR_ZMQ_PORT
|
||||
- BASE_XMR_WALLET_PORT
|
||||
- XMR_WALLET_RPC_HOST
|
||||
- XMR_WALLET_RPC_USER
|
||||
- XMR_WALLET_RPC_PWD
|
||||
- DEFAULT_XMR_RESTORE_HEIGHT
|
||||
- UI_HTML_PORT
|
||||
- PART_ZMQ_PORT
|
||||
- PART_RPC_USER
|
||||
- PART_RPC_PWD
|
||||
- BTC_RPC_USER
|
||||
- BTC_RPC_PWD
|
||||
- LTC_RPC_USER
|
||||
- LTC_RPC_PWD
|
||||
- PART_DATA_DIR
|
||||
- LTC_DATA_DIR
|
||||
- BTC_DATA_DIR
|
||||
- XMR_DATA_DIR
|
||||
- XMR_WALLETS_DIR
|
||||
- COINS_BIND_IP
|
||||
restart: "no"
|
||||
networks:
|
||||
default:
|
||||
external:
|
||||
|
|
21
docker/production/example.env
Normal file
21
docker/production/example.env
Normal file
|
@ -0,0 +1,21 @@
|
|||
HTML_PORT=127.0.0.1:12700:12700
|
||||
TZ=UTC
|
||||
DATA_PATH=/var/swapdata/
|
||||
PART_RPC_HOST=particl_core
|
||||
LTC_RPC_HOST=litecoin_core
|
||||
BTC_RPC_HOST=bitcoin_core
|
||||
|
||||
PART_RPC_USER=particl_user
|
||||
PART_RPC_PWD=particl_pwd
|
||||
BTC_RPC_USER=bitcoin_user
|
||||
BTC_RPC_PWD=bitcoin_pwd
|
||||
LTC_RPC_USER=litecoin_user
|
||||
LTC_RPC_PWD=litecoin_pwd
|
||||
|
||||
PART_DATA_DIR=/data/particl
|
||||
LTC_DATA_DIR=/data/litecoin
|
||||
BTC_DATA_DIR=/data/bitcoin
|
||||
XMR_DATA_DIR=/data/monero_daemon
|
||||
XMR_WALLETS_DIR=/data/monero_wallet
|
||||
|
||||
COINS_BIND_IP=0.0.0.0
|
|
@ -1,13 +1,14 @@
|
|||
FROM i_swapclient as install_stage
|
||||
|
||||
RUN basicswap-prepare --preparebinonly --bindir=/coin_bin --withcoin=litecoin --withoutcoin=particl
|
||||
RUN basicswap-prepare --preparebinonly --bindir=/coin_bin --withcoin=litecoin --withoutcoin=particl && \
|
||||
find /coin_bin -name *.tar.gz -delete
|
||||
|
||||
FROM debian:buster-slim
|
||||
COPY --from=install_stage /coin_bin .
|
||||
|
||||
ENV LITECOIN_DATA /data
|
||||
|
||||
RUN groupadd -r particl && useradd -r -m -g litecoin litecoin \
|
||||
RUN groupadd -r litecoin && useradd -r -m -g litecoin litecoin \
|
||||
&& apt-get update \
|
||||
&& apt-get install -qq --no-install-recommends gosu \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
|
@ -21,4 +22,4 @@ COPY entrypoint.sh /entrypoint.sh
|
|||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
EXPOSE 8332 8333 18332 18333 18443 18444
|
||||
CMD ["litecoind"]
|
||||
CMD ["/litecoin/litecoind", "--datadir=/data"]
|
||||
|
|
|
@ -2,18 +2,16 @@ FROM i_monero_daemon
|
|||
|
||||
ENV MONERO_DATA /data
|
||||
|
||||
RUN groupadd -r monero && useradd -r -m -g monero monero \
|
||||
RUN groupadd -r monero_wallet && useradd -r -m -g monero_wallet monero_wallet \
|
||||
&& apt-get update \
|
||||
&& apt-get install -qq --no-install-recommends gosu \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& mkdir -p "$MONERO_DATA" \
|
||||
&& chown -R monero:monero "$MONERO_DATA" \
|
||||
&& ln -sfn "$MONERO_DATA" /home/monero/.monero \
|
||||
&& chown -h monero:monero /home/monero/.monero
|
||||
&& chown -R monero_wallet:monero_wallet "$MONERO_DATA"
|
||||
VOLUME $MONERO_DATA
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
EXPOSE 18080
|
||||
CMD ["monero-wallet-rpc", "--non-interactive", "--config-file=/home/monero/.monero/monerod.conf"]
|
||||
CMD ["monero-wallet-rpc", "--non-interactive", "--config-file=/data/monero_wallet.conf"]
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [[ "$1" == "monerod" ]]; then
|
||||
if [[ "$1" == "monero-wallet-rpc" ]]; then
|
||||
mkdir -p "$MONERO_DATA"
|
||||
|
||||
chown -h monero:monero /home/monero/.monero
|
||||
exec gosu monero "$@"
|
||||
chown -h monero_wallet:monero_wallet /data
|
||||
exec gosu monero_wallet "$@"
|
||||
else
|
||||
exec "$@"
|
||||
fi
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
FROM i_swapclient as install_stage
|
||||
|
||||
RUN basicswap-prepare --preparebinonly --bindir=/coin_bin --withcoin=particl
|
||||
RUN basicswap-prepare --preparebinonly --bindir=/coin_bin --withcoin=particl && \
|
||||
find /coin_bin -name *.tar.gz -delete
|
||||
|
||||
FROM debian:buster-slim
|
||||
COPY --from=install_stage /coin_bin .
|
||||
|
@ -21,4 +22,4 @@ COPY entrypoint.sh /entrypoint.sh
|
|||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
EXPOSE 51735 20792 51738
|
||||
CMD ["particld"]
|
||||
CMD ["/particl/particld", "--datadir=/data"]
|
||||
|
|
1
docker/production/swapclient/.gitignore
vendored
Normal file
1
docker/production/swapclient/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
test_code
|
|
@ -18,7 +18,12 @@ RUN wget -O basicswap-master.zip https://github.com/tecnovert/basicswap/archive/
|
|||
protoc -I=basicswap --python_out=basicswap basicswap/messages.proto; \
|
||||
pip3 install .;
|
||||
|
||||
RUN useradd -ms /bin/bash swap_user && \
|
||||
#COPY ./test_code basicswap-master
|
||||
#RUN cd basicswap-master; \
|
||||
# protoc -I=basicswap --python_out=basicswap basicswap/messages.proto; \
|
||||
# pip3 install .;
|
||||
|
||||
RUN groupadd -r swap_user && useradd -g swap_user -ms /bin/bash swap_user && \
|
||||
mkdir /data && chown swap_user -R /data
|
||||
|
||||
# Expose html port
|
||||
|
|
Loading…
Reference in a new issue