Commit 8655c7b4 authored by Carlos Natalino's avatar Carlos Natalino
Browse files

Fixing name resolution and Docker image.

parent 879a21a7
Loading
Loading
Loading
Loading

open_webui.sh

0 → 100755
+12 −0
Original line number Diff line number Diff line
# this script opens the webui

WEBUI_PROTO=`kubectl get service/webuiservice -n tf-dev -o jsonpath='{.spec.ports[0].name}'`
WEBUI_IP=`kubectl get service/webuiservice -n tf-dev -o jsonpath='{.spec.clusterIP}'`
WEBUI_PORT=`kubectl get service/webuiservice -n tf-dev -o jsonpath='{.spec.ports[0].port}'`
URL=${WEBUI_PROTO}://${WEBUI_IP}:${WEBUI_PORT}

echo Opening web UI on URL ${URL}

# curl -kL ${URL}

python3 -m webbrowser ${URL}
 No newline at end of file
+3 −3
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ import os
import logging

# General settings
LOG_LEVEL = logging.WARNING
LOG_LEVEL = logging.DEBUG

# gRPC settings
WEBUI_SERVICE_PORT = 8004
@@ -16,8 +16,8 @@ HOST = '0.0.0.0' # accepts connections coming from any ADDRESS

DEBUG=False

CONTEXT_SERVICE_ADDRESS = os.environ.get('CONTEXT_SERVICE_ADDRESS', 'context')
CONTEXT_SERVICE_ADDRESS = os.environ.get('CONTEXTSERVICE_SERVICE_HOST', 'contextservice')
CONTEXT_SERVICE_PORT = 1010

DEVICE_SERVICE_ADDRESS = os.environ.get('DEVICE_SERVICE_ADDRESS', 'device')
DEVICE_SERVICE_ADDRESS = os.environ.get('DEVICESERVICE_SERVICE_HOST', 'deviceservice')
DEVICE_SERVICE_PORT = 2020
+20 −18
Original line number Diff line number Diff line
@@ -14,29 +14,31 @@ ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION='python'
#     wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
#     chmod +x /bin/grpc_health_probe

# Get generic Python packages
RUN python3 -m pip install --upgrade pip setuptools wheel pip-tools
# creating a user for security reasons
RUN groupadd -r webui && useradd --no-log-init -r -m -g webui webui
USER webui

# Set working directory
WORKDIR /var/teraflow

# Create module sub-folders
RUN mkdir -p /var/teraflow/webui
# set working directory
RUN mkdir -p /home/webui/teraflow
WORKDIR /home/webui/teraflow

# Get Python packages per module
COPY webui/requirements.in webui/requirements.in
RUN pip-compile --output-file=webui/requirements.txt webui/requirements.in
RUN python3 -m pip install -r webui/requirements.txt
ENV VIRTUAL_ENV=/home/webui/venv
RUN python3 -m venv ${VIRTUAL_ENV}
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
COPY --chown=webui:webui webui/requirements.in /home/webui/teraflow/webui/requirements.in
RUN pip install --upgrade "pip<22" setuptools wheel pip-tools && pip-compile --output-file=webui/requirements.txt webui/requirements.in
RUN pip install -r webui/requirements.txt

# Add files into working directory
COPY common/. common
COPY context/__init__.py context/__init__.py
COPY context/proto/. context/proto
COPY context/client/. context/client
COPY device/__init__.py device/__init__.py
COPY device/proto/. device/proto
COPY device/client/. device/client
COPY webui/. webui
COPY --chown=webui:webui common/. common
COPY --chown=webui:webui context/__init__.py context/__init__.py
COPY --chown=webui:webui context/proto/. context/proto
COPY --chown=webui:webui context/client/. context/client
COPY --chown=webui:webui device/__init__.py device/__init__.py
COPY --chown=webui:webui device/proto/. device/proto
COPY --chown=webui:webui device/client/. device/client
COPY --chown=webui:webui webui/. webui

# Start webui service
ENTRYPOINT ["python", "-m", "webui.service"]
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ import os
from flask import Flask, session
from flask_healthz import healthz, HealthError

from webui.proto.context_pb2 import Empty
from device.client.DeviceClient import DeviceClient
from context.client.ContextClient import ContextClient
from webui.Config import (CONTEXT_SERVICE_ADDRESS, CONTEXT_SERVICE_PORT,
+4 −1
Original line number Diff line number Diff line
import logging
import sys
from flask import render_template, Blueprint, flash, session
from webui.Config import CONTEXT_SERVICE_ADDRESS, CONTEXT_SERVICE_PORT
from context.client.ContextClient import ContextClient
@@ -8,11 +10,12 @@ main = Blueprint('main', __name__)

context_client: ContextClient = ContextClient(CONTEXT_SERVICE_ADDRESS, CONTEXT_SERVICE_PORT)

logger = logging.getLogger(__name__)

@main.route('/', methods=['GET', 'POST'])
def home():
    # flash('This is an info message', 'info')
    # flash('This is a danger message', 'danger')
    
    context_client.connect()
    response = context_client.ListContextIds(Empty())
    context_client.close()