Skip to content

Commit

Permalink
add webui container
Browse files Browse the repository at this point in the history
  • Loading branch information
reliveyy committed Jun 15, 2020
1 parent 84a22dd commit 7879054
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 5 deletions.
7 changes: 7 additions & 0 deletions images/utils/launcher/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,13 @@ def update_connext(self, parsed):
node = self.nodes["connext"]
self.update_ports(node, parsed)

def update_webui(self, parsed):
"""Update Connext related configurations from parsed TOML raiden section
:param parsed: Parsed raiden TOML section
"""
node = self.nodes.get("webui", None)
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
Expand Down
26 changes: 25 additions & 1 deletion images/utils/launcher/config/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,15 @@ def __eq__(self, other):
"container": "/mnt/hostfs",
},
],
"ports": [PortPublish("28885"), PortPublish("8080")],
"ports": [PortPublish("28885"), PortPublish("8081:8080")],
"mode": "native",
"preserve_config": False,
},
"webui": {
"name": "webui",
"image": "exchangeunion/webui:latest",
"volumes": [],
"ports": [PortPublish("8080")],
"mode": "native",
"preserve_config": False,
}
Expand Down Expand Up @@ -243,6 +251,14 @@ def __eq__(self, other):
"ports": [PortPublish("18885")],
"mode": "native",
"preserve_config": False,
},
"webui": {
"name": "webui",
"image": "exchangeunion/webui:latest",
"volumes": [],
"ports": [PortPublish("8080")],
"mode": "native",
"preserve_config": False,
}
},
"mainnet": {
Expand Down Expand Up @@ -365,6 +381,14 @@ def __eq__(self, other):
"ports": [PortPublish("8885")],
"mode": "native",
"preserve_config": False,
},
"webui": {
"name": "webui",
"image": "exchangeunion/webui:latest",
"volumes": [],
"ports": [PortPublish("8080")],
"mode": "native",
"preserve_config": False,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions images/utils/launcher/node/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .lnd import Lndbtc, Lndltc
from .xud import Xud, XudApiError
from .connext import Connext
from .webui import Webui
from .image import Image, ImageManager

from ..utils import parallel_execute, get_useful_error_message, get_hostfs_file, ArgumentParser
Expand Down
12 changes: 12 additions & 0 deletions images/utils/launcher/node/webui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from .base import Node


class Webui(Node):
def __init__(self, name, ctx):
super().__init__(name, ctx)

self._cli = None
self.api = None

def status(self):
return "Ready"
14 changes: 14 additions & 0 deletions images/webui/latest/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:14-alpine3.11 as builder
ARG REPO=ExchangeUnion/xud-webui-poc
ARG BRANCH=master
RUN apk --no-cache add git
RUN git clone -b $BRANCH https://github.com/$REPO /src
WORKDIR /src
RUN git pull origin $BRANCH
RUN yarn install
RUN yarn build

FROM nginx:1.19.0-alpine
COPY --from=builder /src/build/ /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
RUN mkdir -p /var/nginx/logs
41 changes: 41 additions & 0 deletions images/webui/latest/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
worker_processes 1; ## Default: 1
error_log /var/nginx/logs/error.log;
pid /var/nginx/logs/nginx.pid;
worker_rlimit_nofile 8192;

events {
worker_connections 1024;
}

http {
include mime.types;
index index.html;

default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/nginx/logs/access.log main;
sendfile on;
tcp_nopush on;

server {
listen 8080;
server_name localhost;
root /usr/share/nginx/html;

location /static/ {
}

location /api {
proxy_pass http://xud:8080/api;
}

location ~ \.css {
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
}
}
8 changes: 4 additions & 4 deletions tools/core/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ def _build_platform(self, platform: Platform, no_cache: bool = False) -> bool:

if self._skip_build(platform, unmodified_history):
self._logger.debug("%s Skip building", prefix)
if platform == self.context.current_platform and "TRAVIS_BRANCH" not in os.environ:
tag = self.get_build_tag(self.branch)
self.run_command(f"docker pull {tag}", "Failed to pull " + tag)
self.run_command(f"docker tag {tag} {build_tag}", "Failed to re-tag " + tag)
# if platform == self.context.current_platform and "TRAVIS_BRANCH" not in os.environ:
# tag = self.get_build_tag(self.branch)
# self.run_command(f"docker pull {tag}", "Failed to pull " + tag)
# self.run_command(f"docker tag {tag} {build_tag}", "Failed to re-tag " + tag)
return False

self.print_title("Building {}".format(self.name), "{} ({})".format(self.tag, platform.tag_suffix))
Expand Down

0 comments on commit 7879054

Please sign in to comment.