diff --git a/images/utils/launcher/config/config.py b/images/utils/launcher/config/config.py index 88490164a..7f61555f4 100644 --- a/images/utils/launcher/config/config.py +++ b/images/utils/launcher/config/config.py @@ -114,8 +114,11 @@ def parse_command_line_arguments(self): parser.add_argument("--boltz.disabled", nargs='?') - parser.add_argument("--use-local-images") + parser.add_argument("--webui.disabled", nargs='?') + parser.add_argument("--webui.expose-ports") + parser.add_argument("--dev", action="store_true") + parser.add_argument("--use-local-images") self.args = parser.parse_args() self.logger.info("Parsed command-line arguments: %r", self.args) @@ -161,10 +164,12 @@ def update_volume(self, volumes, container_dir, host_dir): target = target[0] target["host"] = host_dir - def update_ports(self, node, parsed): + def update_ports(self, node, parsed, mapping=None): if "expose-ports" in parsed: value = parsed["expose-ports"] for p in value: + if mapping and p in mapping: + p = mapping[p] p = PortPublish(str(p)) if p not in node["ports"]: node["ports"].append(p) @@ -172,6 +177,8 @@ def update_ports(self, node, parsed): if hasattr(self.args, opt): value = getattr(self.args, opt) for p in value.split(","): + if mapping and p in mapping: + p = mapping[p] p = PortPublish(p.strip()) if p not in node["ports"]: node["ports"].append(p) @@ -394,21 +401,35 @@ def update_lndltc(self, parsed): self.update_ports(node, parsed) def update_connext(self, parsed): - """Update Connext related configurations from parsed TOML raiden section + """Update Connext related configurations from parsed TOML connext section :param parsed: Parsed raiden TOML section """ node = self.nodes["connext"] self.update_ports(node, parsed) - def update_raiden(self, parsed): - """Update raiden related configurations from parsed TOML raiden section - :param parsed: Parsed raiden TOML section + def update_xud(self, parsed): + """Update xud related configurations from parsed TOML xud section + :param parsed: Parsed xud TOML section """ - if self.network in ["simnet", "testnet", "mainnet"]: - return - node = self.nodes["raiden"] + node = self.nodes["xud"] self.update_ports(node, parsed) + def update_disabled(self, node, parsed, opt): + if "disabled" in parsed: + value = parsed["disabled"] + assert isinstance(value, bool) + node["disabled"] = value + if hasattr(self.args, opt): + value: str = getattr(self.args, opt) + if value: + value = value.strip().lower() + if not value or value == "true" or value == "": + node["disabled"] = True + elif value == "false": + node["disabled"] = False + else: + raise ValueError("Invalid value of option \"{}\": {}".format(opt, value)) + def update_arby(self, parsed): """Update arby related configurations from parsed TOML arby section :param parsed: Parsed xud TOML section @@ -474,41 +495,28 @@ def update_arby(self, parsed): if value: node["margin"] = value - if "disabled" in parsed: - value = parsed["disabled"] - assert isinstance(value, bool) - node["disabled"] = value - opt = "arby.disabled" - if hasattr(self.args, opt): - value: str = getattr(self.args, opt) - if value: - value = value.strip().lower() - if not value or value == "true" or value == "": - node["disabled"] = True - elif value == "false": - node["disabled"] = False - else: - raise ValueError("Invalid value of option \"arby.disabled\": {}".format(value)) - + self.update_disabled(node, parsed, "arby.disabled") self.update_ports(node, parsed) - def update_xud(self, parsed): - """Update xud related configurations from parsed TOML xud section - :param parsed: Parsed xud TOML section + def update_boltz(self, parsed): + """Update webui related configurations from parsed TOML boltz section + :param parsed: Parsed raiden TOML section """ - node = self.nodes["xud"] + node = self.nodes["boltz"] + self.update_disabled(node, parsed, "boltz.disabled") self.update_ports(node, parsed) - def update_ltcd(self, parsed): - """Update ltcd related configurations from parsed TOML ltcd section - :param parsed: Parsed ltcd TOML section + def update_webui(self, parsed): + """Update webui related configurations from parsed TOML webui section + :param parsed: Parsed raiden TOML section """ - node = self.nodes["ltcd"] - self.update_ports(node, parsed) - - def update_boltz(self, parsed): - node = self.nodes["boltz"] - self.update_ports(node, parsed) + node = self.nodes["webui"] + self.update_disabled(node, parsed, "webui.disabled") + self.update_ports(node, parsed, mapping={ + "8888": "8888:8080", + "18888": "18888:8080", + "28888": "28888:8080", + }) def parse_network_config(self): network = self.network diff --git a/images/utils/launcher/config/mainnet.conf b/images/utils/launcher/config/mainnet.conf index e091b1f17..34850f63e 100644 --- a/images/utils/launcher/config/mainnet.conf +++ b/images/utils/launcher/config/mainnet.conf @@ -128,3 +128,7 @@ #binance-api-secret = "your api secret" #margin = "0.04" #disabled = false + +[webui] +#disabled = false +#expose-ports = ["8888:8080"] diff --git a/images/utils/launcher/config/simnet.conf b/images/utils/launcher/config/simnet.conf index ca9ba904c..87a90b458 100644 --- a/images/utils/launcher/config/simnet.conf +++ b/images/utils/launcher/config/simnet.conf @@ -41,3 +41,7 @@ #binance-api-secret = "your api secret" #margin = "0.04" #disabled = false + +[webui] +#disabled = false +#expose-ports = ["28888:8080"] diff --git a/images/utils/launcher/config/template.py b/images/utils/launcher/config/template.py index e41c6dc37..988e27334 100644 --- a/images/utils/launcher/config/template.py +++ b/images/utils/launcher/config/template.py @@ -118,6 +118,21 @@ def __eq__(self, other): "disabled": True, "use_local_image": False, }, + "webui": { + "name": "webui", + "image": "exchangeunion/webui:latest", + "volumes": [ + { + "host": "$data_dir/xud", + "container": "/root/.xud", + } + ], + "ports": [PortPublish("28888:8080")], + "mode": "native", + "preserve_config": False, + "use_local_image": False, + "disabled": True, + }, "xud": { "name": "xud", "image": "exchangeunion/xud:latest", @@ -143,7 +158,7 @@ def __eq__(self, other): "mode": "native", "preserve_config": False, "use_local_image": False, - } + }, }, "testnet": { "bitcoind": { @@ -290,6 +305,21 @@ def __eq__(self, other): "disabled": False, "use_local_image": False, }, + "webui": { + "name": "webui", + "image": "exchangeunion/webui:latest", + "volumes": [ + { + "host": "$data_dir/xud", + "container": "/root/.xud", + } + ], + "ports": [PortPublish("18888:8080")], + "mode": "native", + "preserve_config": False, + "use_local_image": False, + "disabled": True, + }, "xud": { "name": "xud", "image": "exchangeunion/xud:latest", @@ -315,7 +345,7 @@ def __eq__(self, other): "mode": "native", "preserve_config": False, "use_local_image": False, - } + }, }, "mainnet": { "bitcoind": { @@ -461,6 +491,21 @@ def __eq__(self, other): "disabled": False, "use_local_image": False, }, + "webui": { + "name": "webui", + "image": "exchangeunion/webui:latest", + "volumes": [ + { + "host": "$data_dir/xud", + "container": "/root/.xud", + } + ], + "ports": [PortPublish("8888:8080")], + "mode": "native", + "preserve_config": False, + "use_local_image": False, + "disabled": True, + }, "xud": { "name": "xud", "image": "exchangeunion/xud:1.0.0-beta.4", @@ -486,7 +531,7 @@ def __eq__(self, other): "mode": "native", "preserve_config": False, "use_local_image": False, - } + }, } } diff --git a/images/utils/launcher/config/testnet.conf b/images/utils/launcher/config/testnet.conf index 3f0272d6a..518de38c6 100644 --- a/images/utils/launcher/config/testnet.conf +++ b/images/utils/launcher/config/testnet.conf @@ -131,3 +131,7 @@ [boltz] #disabled = false + +[webui] +#disabled = false +#expose-ports = ["18888:8080"] diff --git a/images/utils/launcher/node/__init__.py b/images/utils/launcher/node/__init__.py index efe8def0c..252fa917d 100644 --- a/images/utils/launcher/node/__init__.py +++ b/images/utils/launcher/node/__init__.py @@ -19,6 +19,7 @@ from .geth import Geth from .image import Image, ImageManager from .lnd import Lndbtc, Lndltc +from .webui import Webui from .xud import Xud, XudApiError from ..config import Config from ..errors import FatalError diff --git a/images/utils/launcher/node/webui.py b/images/utils/launcher/node/webui.py new file mode 100644 index 000000000..db989fdfd --- /dev/null +++ b/images/utils/launcher/node/webui.py @@ -0,0 +1,9 @@ +from .base import Node + + +class Webui(Node): + def __init__(self, name, ctx): + super().__init__(name, ctx) + + def status(self): + return "Ready" diff --git a/images/webui/latest/Dockerfile b/images/webui/latest/Dockerfile new file mode 100644 index 000000000..05f590126 --- /dev/null +++ b/images/webui/latest/Dockerfile @@ -0,0 +1,28 @@ +FROM node:14-alpine as builder +RUN apk --no-cache add git + +RUN git clone -b socketio https://github.com/ExchangeUnion/xud-webui-poc /src/frontend +WORKDIR /src/frontend +RUN git fetch && git checkout b94cb330 +RUN yarn install +RUN yarn build + +RUN git clone -b dev https://github.com/ExchangeUnion/xud-socketio /src/backend +WORKDIR /src/backend +RUN git fetch && git checkout a3fd8648 +RUN sed -Ei 's/^.*grpc-tools.*$//g' package.json +RUN yarn install +RUN apk --no-cache add bash +RUN yarn build + + +FROM node:14-alpine +COPY --from=builder /src/backend/node_modules /app/node_modules +COPY --from=builder /src/backend/dist /app/dist +COPY --from=builder /src/backend/bin /app/bin +COPY --from=builder /src/frontend/build /app/public +COPY entrypoint.sh / +WORKDIR /app +RUN apk --no-cache add supervisor +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf +ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/images/webui/latest/Dockerfile.aarch64 b/images/webui/latest/Dockerfile.aarch64 new file mode 100644 index 000000000..807e3b1f8 --- /dev/null +++ b/images/webui/latest/Dockerfile.aarch64 @@ -0,0 +1,29 @@ +FROM node:14-alpine as builder +RUN apk --no-cache add git + +RUN git clone -b socketio https://github.com/ExchangeUnion/xud-webui-poc /src/frontend +WORKDIR /src/frontend +RUN git fetch && git checkout b94cb330 +RUN yarn install +RUN yarn build + +RUN git clone -b dev https://github.com/ExchangeUnion/xud-socketio /src/backend +WORKDIR /src/backend +RUN git fetch && git checkout a3fd8648 +RUN sed -Ei 's/^.*grpc-tools.*$//g' package.json +RUN apk --no-cache add python3 make g++ +RUN yarn install +RUN apk --no-cache add bash +RUN yarn build + + +FROM node:14-alpine +COPY --from=builder /src/backend/node_modules /app/node_modules +COPY --from=builder /src/backend/dist /app/dist +COPY --from=builder /src/backend/bin /app/bin +COPY --from=builder /src/frontend/build /app/public +COPY entrypoint.sh / +WORKDIR /app +RUN apk --no-cache add supervisor +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf +ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/images/webui/latest/entrypoint.sh b/images/webui/latest/entrypoint.sh new file mode 100755 index 000000000..567a003ba --- /dev/null +++ b/images/webui/latest/entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +case $NETWORK in + simnet) + RPCPORT=28886 + ;; + testnet) + RPCPORT=18886 + ;; + mainnet) + RPCPORT=8886 + ;; + *) + echo "Invalid NETWORK" + exit 1 +esac + +while ! [ -e /root/.xud/tls.cert ]; do + echo "Waiting for /root/.xud/tls.cert" + sleep 1 +done + +exec bin/server --xud.rpchost=xud --xud.rpcport=$RPCPORT --xud.rpccert=/root/.xud/tls.cert diff --git a/images/webui/latest/supervisord.conf b/images/webui/latest/supervisord.conf new file mode 100644 index 000000000..4de5347fd --- /dev/null +++ b/images/webui/latest/supervisord.conf @@ -0,0 +1,11 @@ +[supervisord] +nodaemon=true +logfile=/supervisord.log +childlogdir=/app +user=root + +[program:webui] +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +command=/entrypoint.sh +stopsignal=SIGINT diff --git a/requirements-dev.txt b/requirements-dev.txt index 9d45dc214..7dd345b8d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,3 +5,5 @@ pytest-html pytest-integration pytest-timeout pytest-dotenv +toml +demjson