Skip to content

Commit

Permalink
feat: use xud default ports like 8886, 18886, 28886 (#395)
Browse files Browse the repository at this point in the history
* use xud default ports like 8886, 18886, 28886

* fix xucli create

* remove --rpcport for xucli

* use xud:latest (master) in testnet

* Update images/xud/latest/xud-backup.sh

Co-Authored-By: Kilian Rausch ⚡️ <kilian.rausch@gmail.com>

Co-authored-by: Kilian Rausch ⚡️ <kilian.rausch@gmail.com>
  • Loading branch information
reliveyy and kilrau authored Apr 20, 2020
1 parent d7360d5 commit aceb72b
Show file tree
Hide file tree
Showing 15 changed files with 303 additions and 132 deletions.
3 changes: 2 additions & 1 deletion images/raiden/0.100.5a1.dev162-2217bcb/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ ADDRESS=$(get_addr)
OPTS=(
"--rpc"
"--accept-disclaimer"
"--resolver-endpoint http://xud:8887/resolveraiden"
"--eth-rpc-endpoint $RPC_ENDPOINT"
"--password-file $RAIDEN_DIR/passphrase.txt"
"--datadir $RAIDEN_DIR"
Expand All @@ -70,6 +69,7 @@ testnet)
"--user-deposit-contract-address 0x3A17B96809258523c4DED8e7F3f9364D13eBc2C5"
"--monitoring-service-contract-address 0x9F50cEA29307d7D91c5176Af42f3aB74f0190dD3"
"--one-to-n-contract-address 0xA102879b6AE21B93432160532DeB8f0EA1C50b30"
"--resolver-endpoint http://xud:18887/resolveraiden"
)
;;
mainnet)
Expand All @@ -85,6 +85,7 @@ mainnet)
"--user-deposit-contract-address 0x4F26957E8fd331D53DD60feE77533FBE7564F5Fe"
"--monitoring-service-contract-address 0x37cC37D7703554183aE544391945e7D0588b7693"
"--one-to-n-contract-address 0x3dda5BE50Af796618d9f48c021Cf0C9FD64FFeb1"
"--resolver-endpoint http://xud:8887/resolveraiden"
)
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion images/utils/launcher/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def __eq__(self, other):
},
"xud": {
"name": "xud",
"image": "exchangeunion/xud:1.0.0-beta.2",
"image": "exchangeunion/xud:latest",
"volumes": [
{
"host": "$data_dir/xud",
Expand Down
8 changes: 2 additions & 6 deletions images/xud/1.0.0-beta.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
FROM node:12-alpine3.11 AS builder
ARG REPO=ExchangeUnion/xud
ARG BRANCH=v1.0.0-beta.2
# Use pure JS implemented secp256k1 bindings
RUN apk add --no-cache git rsync bash musl-dev go python3 make g++
# This is a "hack" to automatically invalidate the cache in case there are new commits
#ADD https://api.github.com/repos/$REPO/commits/$BRANCH /dev/null
ADD https://api.github.com/repos/$REPO/commits/$BRANCH /dev/null
RUN git clone -b $BRANCH --depth=2 https://github.com/$REPO
WORKDIR /xud
RUN git show HEAD > git_head.txt
RUN npm install
RUN npm run compile
RUN npm run compile:seedutil
Expand All @@ -18,7 +16,6 @@ RUN rm -rf seedutil/go
FROM node:12-alpine3.11
RUN apk add --no-cache bash supervisor tor
COPY --from=builder /xud /app
COPY xud.conf /tmp/
COPY entrypoint.sh xud-backup.sh /app/
COPY start_tor.sh update-backup-dir.sh /
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
Expand All @@ -27,5 +24,4 @@ RUN ln -s /app/bin/xucli /usr/local/bin/xucli
RUN mkdir -p /root/.xud/tor
WORKDIR /app
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
VOLUME [ "/root/.xud" ]
EXPOSE 8885 18885 8887
EXPOSE 8887 18887 28887
7 changes: 2 additions & 5 deletions images/xud/1.0.0-beta.2/Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ RUN apk add --no-cache git rsync bash musl-dev go python3 make g++
# python: not found
RUN apk add --no-cache python
# This is a "hack" to automatically invalidate the cache in case there are new commits
#ADD https://api.github.com/repos/$REPO/commits/$BRANCH /dev/null
ADD https://api.github.com/repos/$REPO/commits/$BRANCH /dev/null
RUN git clone -b $BRANCH --depth=2 https://github.com/$REPO
WORKDIR /xud
RUN git show HEAD > git_head.txt
RUN cp package.json /tmp/package.json
RUN sed -Ei 's/"grpc-tools": "1.8.0",//g' package.json
RUN npm install
Expand All @@ -24,7 +23,6 @@ RUN rm -rf seedutil/go
FROM node:12-alpine3.11
RUN apk add --no-cache bash supervisor tor
COPY --from=builder /xud /app
COPY xud.conf /tmp/
COPY entrypoint.sh xud-backup.sh /app/
COPY start_tor.sh update-backup-dir.sh /
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
Expand All @@ -33,5 +31,4 @@ RUN ln -s /app/bin/xucli /usr/local/bin/xucli
RUN mkdir -p /root/.xud/tor
WORKDIR /app
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
VOLUME [ "/root/.xud" ]
EXPOSE 8885 18885 8887
EXPOSE 8887 18887 28887
86 changes: 54 additions & 32 deletions images/xud/1.0.0-beta.2/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
#!/bin/bash

XUD_DIR=$HOME/.xud
XUD_CONF=$XUD_DIR/xud.conf
KEYSTORE_DIR=$HOME/.raiden/keystore

[[ -e $KEYSTORE_DIR ]] || mkdir -p "$KEYSTORE_DIR"

case $NETWORK in
mainnet)
P2P_PORT=8885
RPC_PORT=8886
HTTP_PORT=8887
;;
testnet)
P2P_PORT=18885
RPC_PORT=18886
HTTP_PORT=18887
;;
simnet)
P2P_PORT=28885
RPC_PORT=28886
HTTP_PORT=28887
;;
*)
echo >&2 "Error: Unsupported network: $NETWORK"
exit 1
esac

wait_file() {
local file="$1"; shift
local wait_seconds="${1:-10}"; shift # after 10 seconds we give up
Expand All @@ -10,40 +37,35 @@ wait_file() {
}

write_config() {
echo "xud.conf not found - creating a new one..."
cp /tmp/xud.conf ~/.xud

hn="$(hostname)"
n="${hn:3}"

if [[ -z $n ]]; then
insid="0"
else
insid="$n"
fi

case $NETWORK in
mainnet)
DELTA=0
;;
testnet)
DELTA=10000
;;
esac

sed -i "s/<instance_id>/$insid/g" ~/.xud/xud.conf
sed -i "s/<network>/$NETWORK/g" ~/.xud/xud.conf
sed -i "s/<p2p_port>/$((8885 + DELTA))/g" ~/.xud/xud.conf

XUD_HOSTNAME="/root/.xud/tor/hostname"
wait_file "$XUD_HOSTNAME" && {
XUD_ONION_ADDRESS=$(cat $XUD_HOSTNAME)
echo "Onion address for xud is $XUD_ONION_ADDRESS"
sed -i "s/<onion_address>/$XUD_ONION_ADDRESS/g" ~/.xud/xud.conf
}
echo "xud.conf not found - creating a new one..."
cp /app/sample-xud.conf $XUD_CONF

XUD_HOSTNAME="/root/.xud/tor/hostname"
wait_file "$XUD_HOSTNAME" && {
XUD_ONION_ADDRESS=$(cat $XUD_HOSTNAME)
echo "Onion address for xud is $XUD_ONION_ADDRESS"
}

sed -i "s/network.*/network = \"$NETWORK\"/" $XUD_CONF
sed -i 's/noencrypt.*/noencrypt = false/' $XUD_CONF
sed -i '/\[http/,/^$/s/host.*/host = "0.0.0.0"/' $XUD_CONF
sed -i "/\[http/,/^$/s/port.*/port = $HTTP_PORT/" $XUD_CONF
sed -i '/\[lnd\.BTC/,/^$/s/host.*/host = "lndbtc"/' $XUD_CONF
sed -i "/\[lnd\.BTC/,/^$/s|^$|certpath = \"/root/.lndbtc/tls.cert\"\nmacaroonpath = \"/root/.lndbtc/data/chain/bitcoin/$NETWORK/admin.macaroon\"\n|" $XUD_CONF
sed -i '/\[lnd\.LTC/,/^$/s/host.*/host = "lndltc"/' $XUD_CONF
sed -i '/\[lnd\.LTC/,/^$/s/port.*/port = 10009/' $XUD_CONF
sed -i "/\[lnd\.LTC/,/^$/s|^$|certpath = \"/root/.lndltc/tls.cert\"\nmacaroonpath = \"/root/.lndltc/data/chain/litecoin/$NETWORK/admin.macaroon\"\n|" $XUD_CONF
sed -i "/\[p2p/,/^$/s/addresses.*/addresses = \[\"$XUD_ONION_ADDRESS\"]/" $XUD_CONF
sed -i "/\[p2p/,/^$/s/port.*/port = $P2P_PORT/" $XUD_CONF
sed -i '/\[p2p/,/^$/s/tor = .*/tor = true/' $XUD_CONF
sed -i '/\[p2p/,/^$/s/torport.*/torport = 9050/' $XUD_CONF
sed -i '/\[raiden/,/^$/s/host.*/host = "raiden"/' $XUD_CONF
sed -i "/\[raiden/,/^$/s|^$|keystorepath = \"$KEYSTORE_DIR\"\n|" $XUD_CONF
sed -i '/\[rpc/,/^$/s/host.*/host = "0.0.0.0"/' $XUD_CONF
sed -i "/\[rpc/,/^$/s/port.*/port = $RPC_PORT/" $XUD_CONF
}

if [[ $XUD_REWRITE_CONFIG || ! -e ~/.xud/xud.conf ]]; then
if [[ $XUD_REWRITE_CONFIG || ! -e $XUD_CONF ]]; then
write_config
fi

Expand Down
86 changes: 0 additions & 86 deletions images/xud/1.0.0-beta.2/xud.conf

This file was deleted.

27 changes: 27 additions & 0 deletions images/xud/latest/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM node:12-alpine3.11 AS builder
ARG REPO=ExchangeUnion/xud
ARG BRANCH=master
RUN apk add --no-cache git rsync bash musl-dev go python3 make g++
# This is a "hack" to automatically invalidate the cache in case there are new commits
ADD https://api.github.com/repos/$REPO/commits/$BRANCH /dev/null
RUN git clone -b $BRANCH --depth=2 https://github.com/$REPO
WORKDIR /xud
RUN npm install
RUN npm run compile
RUN npm run compile:seedutil
RUN npm prune --production
RUN rm -rf seedutil/go


FROM node:12-alpine3.11
RUN apk add --no-cache bash supervisor tor
COPY --from=builder /xud /app
COPY entrypoint.sh xud-backup.sh /app/
COPY start_tor.sh update-backup-dir.sh /
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY torrc /etc/tor/torrc
RUN ln -s /app/bin/xucli /usr/local/bin/xucli
RUN mkdir -p /root/.xud/tor
WORKDIR /app
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
EXPOSE 8887 18887 28887
34 changes: 34 additions & 0 deletions images/xud/latest/Dockerfile.aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM node:12-alpine3.11 AS builder
ARG REPO=ExchangeUnion/xud
ARG BRANCH=v1.0.0-beta.2
# Use pure JS implemented secp256k1 bindings
RUN apk add --no-cache git rsync bash musl-dev go python3 make g++
# Pre-built binaries not found for sqlite3@4.1.0 and node@12.16.1 (node-v72 ABI, musl) (falling back to source compile with node-gyp)
# python: not found
RUN apk add --no-cache python
# This is a "hack" to automatically invalidate the cache in case there are new commits
ADD https://api.github.com/repos/$REPO/commits/$BRANCH /dev/null
RUN git clone -b $BRANCH --depth=2 https://github.com/$REPO
WORKDIR /xud
RUN cp package.json /tmp/package.json
RUN sed -Ei 's/"grpc-tools": "1.8.0",//g' package.json
RUN npm install
RUN cp /tmp/package.json package.json
RUN npm run compile
RUN npm run compile:seedutil
RUN npm prune --production
RUN rm -rf seedutil/go


FROM node:12-alpine3.11
RUN apk add --no-cache bash supervisor tor
COPY --from=builder /xud /app
COPY entrypoint.sh xud-backup.sh /app/
COPY start_tor.sh update-backup-dir.sh /
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY torrc /etc/tor/torrc
RUN ln -s /app/bin/xucli /usr/local/bin/xucli
RUN mkdir -p /root/.xud/tor
WORKDIR /app
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
EXPOSE 8887 18887 28887
Loading

0 comments on commit aceb72b

Please sign in to comment.