diff --git a/notebooks/Experimental/Veilid/Alice-Veilid-Peer.ipynb b/notebooks/Testing/Veilid/Alice-Veilid-Peer.ipynb similarity index 100% rename from notebooks/Experimental/Veilid/Alice-Veilid-Peer.ipynb rename to notebooks/Testing/Veilid/Alice-Veilid-Peer.ipynb diff --git a/notebooks/Experimental/Veilid/Bob-Veilid-Peer.ipynb b/notebooks/Testing/Veilid/Bob-Veilid-Peer.ipynb similarity index 100% rename from notebooks/Experimental/Veilid/Bob-Veilid-Peer.ipynb rename to notebooks/Testing/Veilid/Bob-Veilid-Peer.ipynb diff --git a/notebooks/Experimental/Veilid/utils.py b/notebooks/Testing/Veilid/utils.py similarity index 100% rename from notebooks/Experimental/Veilid/utils.py rename to notebooks/Testing/Veilid/utils.py diff --git a/packages/grid/veilid/requirements.txt b/packages/grid/veilid/requirements.txt index 7ed60dc1854..4540e75958c 100644 --- a/packages/grid/veilid/requirements.txt +++ b/packages/grid/veilid/requirements.txt @@ -1,3 +1 @@ -flask==2.3.2 -flask_shell2http==1.9.1 veilid==0.2.5 diff --git a/packages/grid/veilid/start.sh b/packages/grid/veilid/start.sh index 8917fc3ea91..a11d10a131e 100644 --- a/packages/grid/veilid/start.sh +++ b/packages/grid/veilid/start.sh @@ -1,7 +1,4 @@ #!/usr/bin/env bash -export PATH="/root/.local/bin:${PATH}" -export FLASK_APP=veilid -/veilid/veilid-server -c /veilid/veilid-server.conf --debug & -flask run -p 4000 --host=0.0.0.0 +/veilid/veilid-server -c /veilid/veilid-server.conf --debug diff --git a/packages/grid/veilid/veilid.dockerfile b/packages/grid/veilid/veilid.dockerfile index d30f68e14cb..314f1f7787c 100644 --- a/packages/grid/veilid/veilid.dockerfile +++ b/packages/grid/veilid/veilid.dockerfile @@ -1,12 +1,14 @@ +# ======== [Stage 1] Build Veilid Server ========== # + FROM rust as build RUN apt update && apt install -y git RUN git clone -b v0.2.5 https://gitlab.com/veilid/veilid WORKDIR /veilid RUN bash -c "source scripts/earthly/install_capnproto.sh" RUN bash -c "source scripts/earthly/install_protoc.sh" -RUN cd veilid-server && cargo build --release -p veilid-server -p veilid-cli -p veilid-tools -p veilid-core +RUN cd veilid-server && cargo build --release -p veilid-server -RUN cp /veilid/target/release/veilid-server /app +# ========== [Stage 2] Dependency Install ========== # FROM python:3.11-bookworm COPY --from=build /veilid/target/release/veilid-server /veilid/veilid-server @@ -18,11 +20,15 @@ COPY ./start.sh /app/start.sh RUN chmod +x /app/start.sh COPY ./veilid.py /app/veilid.py COPY ./veilid-server.conf /veilid + +# ========== [Final] Start Veilid Server and Python Web Server ========== # + CMD ["sh", "-c", "/app/start.sh"] EXPOSE 5959/udp EXPOSE 5959 EXPOSE 4000 RUN apt update && apt install netcat-openbsd + # docker build -f veilid.dockerfile . -t veilid # docker run -it -p 4000:4000 -p 5959:5959 -p 5959:5959/udp veilid # /root/.local/share/veilid \ No newline at end of file diff --git a/packages/grid/veilid/veilid.py b/packages/grid/veilid/veilid.py index fc1e1d64ba6..e69de29bb2d 100644 --- a/packages/grid/veilid/veilid.py +++ b/packages/grid/veilid/veilid.py @@ -1,93 +0,0 @@ -# stdlib -import functools -import os -from typing import Any -from typing import Callable -from typing import Type - -# third party -from flask import Flask -from flask_executor import Executor -from flask_shell2http import Shell2HTTP - -# Flask application instance -app = Flask(__name__) - -executor = Executor(app) -shell2http = Shell2HTTP(app=app, executor=executor, base_url_prefix="/commands/") - -# key = os.environ.get("STACK_API_KEY", None) # Get key from environment -# if key is None: -# print("No STACK_API_KEY found, exiting.") -# sys.exit(1) - - -def check_stack_api_key(challenge_key: str) -> bool: - key = os.environ.get("STACK_API_KEY", None) # Get key from environment - if key is None: - return False - if challenge_key == key: - return True - return False - - -def basic_auth_check(f: Any) -> Callable: - @functools.wraps(f) - def inner_decorator(*args: Any, **kwargs: Any) -> Type: - # stack_api_key = request.headers.get("X-STACK-API-KEY", "") - # if not check_stack_api_key(challenge_key=stack_api_key): - # raise Exception("STACK_API_KEY doesn't match.") - return f(*args, **kwargs) - - return inner_decorator - - -# def down_callback(context: Dict, future: Future) -> None: -# # optional user-defined callback function -# print(context, future.result()) - - -# def up_callback(context: Dict, future: Future) -> None: -# # optional user-defined callback function -# print(context, future.result()) - - -# shell2http.register_command( -# endpoint="down", -# command_name="tailscale down", -# callback_fn=down_callback, -# decorators=[basic_auth_check], -# ) - -# shell2http.register_command( -# endpoint="up", -# command_name="tailscale up", -# callback_fn=up_callback, -# decorators=[basic_auth_check], -# ) - - -# def status_callback(context: Dict, future: Future) -> None: -# # optional user-defined callback function -# print(context, future.result()) - - -# shell2http.register_command( -# endpoint="status", -# command_name="tailscale status", -# callback_fn=status_callback, -# decorators=[basic_auth_check], -# ) - - -# def debug_prefs_callback(context: Dict, future: Future) -> None: -# # optional user-defined callback function -# print(context, future.result()) - - -# shell2http.register_command( -# endpoint="debug", -# command_name="tailscale debug prefs", -# callback_fn=debug_prefs_callback, -# decorators=[basic_auth_check], -# )