From 0df7bdd970e0f4813d9a964a4d195ff7dccb3661 Mon Sep 17 00:00:00 2001 From: frikky Date: Thu, 17 Feb 2022 23:06:01 +0100 Subject: [PATCH] Added sample proxy server for testing with orborus --- backend/go-app/go.mod | 2 +- docker-compose.yml | 5 +- frontend/src/views/AngularWorkflow.jsx | 10 ++- frontend/src/views/GettingStarted.jsx | 94 ++++++++++++------------ functions/onprem/orborus/build.sh | 2 +- functions/onprem/orborus/proxy_server.py | 54 ++++++++++++++ functions/onprem/orborus/run.sh | 13 ++-- 7 files changed, 120 insertions(+), 60 deletions(-) create mode 100644 functions/onprem/orborus/proxy_server.py diff --git a/backend/go-app/go.mod b/backend/go-app/go.mod index fba0f78f..86e33d11 100644 --- a/backend/go-app/go.mod +++ b/backend/go-app/go.mod @@ -24,7 +24,7 @@ require ( github.com/h2non/filetype v1.1.3 github.com/nirasan/go-oauth-pkce-code-verifier v0.0.0-20170819232839-0fbfe93532da // indirect github.com/satori/go.uuid v1.2.0 - github.com/shuffle/shuffle-shared v0.1.98 + github.com/shuffle/shuffle-shared v0.2.3 go4.org v0.0.0-20201209231011-d4a079459e60 // indirect golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce google.golang.org/api v0.65.0 diff --git a/docker-compose.yml b/docker-compose.yml index a6b6fc0d..4eacbeb7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: frontend: - build: ./frontend + #build: ./frontend image: ghcr.io/frikky/shuffle-frontend:nightly container_name: shuffle-frontend hostname: shuffle-frontend @@ -16,7 +16,7 @@ services: depends_on: - backend backend: - build: ./backend + #build: ./backend image: ghcr.io/frikky/shuffle-backend:nightly container_name: shuffle-backend hostname: ${BACKEND_HOSTNAME} @@ -48,7 +48,6 @@ services: - /var/run/docker.sock:/var/run/docker.sock environment: - SHUFFLE_WORKER_VERSION=nightly - - ORG_ID=${ORG_ID} - ENVIRONMENT_NAME=${ENVIRONMENT_NAME} - BASE_URL=http://${OUTER_HOSTNAME}:${BACKEND_PORT} - DOCKER_API_VERSION=1.40 diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index 99d69f0b..952cb4d1 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -659,7 +659,8 @@ const AngularWorkflow = (defaultprops) => { }); const newitem = removeParam("execution_id", cursearch); - props.history.push(curpath + newitem); + navigate(curpath + newitem) + //props.history.push(curpath + newitem); } } } @@ -3576,7 +3577,8 @@ const AngularWorkflow = (defaultprops) => { ) { setExecutionModalOpen(true) const newitem = removeParam("execution_highlight", cursearch); - props.history.push(curpath + newitem); + navigate(curpath + newitem) + //props.history.push(curpath + newitem); } const tmpView = new URLSearchParams(cursearch).get("view"); @@ -3588,7 +3590,9 @@ const AngularWorkflow = (defaultprops) => { setExecutionModalOpen(true); const newitem = removeParam("view", cursearch); - props.history.push(curpath + newitem); + navigate(curpath + newitem) + //navigate(`?execution_highlight=${parsed_url}`) + //props.history.push(curpath + newitem); } return; } diff --git a/frontend/src/views/GettingStarted.jsx b/frontend/src/views/GettingStarted.jsx index 76bde71c..03c6f280 100644 --- a/frontend/src/views/GettingStarted.jsx +++ b/frontend/src/views/GettingStarted.jsx @@ -2226,53 +2226,55 @@ const GettingStarted = (props) => { return (
- { - setVideoViewOpen(false) - }} - PaperProps={{ - style: { - backgroundColor: surfaceColor, - color: "white", - minWidth: 560, - minHeight: 415, - textAlign: "center", - }, - }} - > - - Welcome to Shuffle! - - - - { - e.preventDefault(); - setVideoViewOpen(false) - }} - > - - - - - - + + Welcome to Shuffle! + + + + { + e.preventDefault(); + setVideoViewOpen(false) + }} + > + + + + + + + : null}
Getting Started with Shuffle diff --git a/functions/onprem/orborus/build.sh b/functions/onprem/orborus/build.sh index f4e445c1..5226f32f 100644 --- a/functions/onprem/orborus/build.sh +++ b/functions/onprem/orborus/build.sh @@ -1,5 +1,5 @@ NAME=shuffle-orborus -VERSION=0.9.58 +VERSION=0.9.59 echo "Running docker build with $NAME:$VERSION" #docker rmi frikky/shuffle:$NAME --force diff --git a/functions/onprem/orborus/proxy_server.py b/functions/onprem/orborus/proxy_server.py new file mode 100644 index 00000000..8020616c --- /dev/null +++ b/functions/onprem/orborus/proxy_server.py @@ -0,0 +1,54 @@ +# +# curl -H "Org-id: Shuffle" --proxy "http://192.168.86.45:8081" http://192.168.86.45:5001/api/v1/workflows/queue + +import SocketServer +import SimpleHTTPServer +import requests +import json + +PORT = 8082 + +class MyProxy(SimpleHTTPServer.SimpleHTTPRequestHandler): + def do_GET(self): + url=self.path[:] + allheaders = {} + for item in ("%s" % self.headers).split("\n"): + headersplit = item.split(":") + if len(headersplit) == 2: + allheaders[headersplit[0]] = (headersplit[1][:-1]).strip() + + ret = requests.get(url, headers=allheaders) + print("RESP (%s) - %d - %s" % (url, ret.status_code, ret.text)) + + self.send_response(ret.status_code) + self.end_headers() + self.wfile.write(ret.text) + + def do_POST(self): + url=self.path[:] + allheaders = {} + for item in ("%s" % self.headers).split("\n"): + headersplit = item.split(":") + if len(headersplit) == 2: + allheaders[headersplit[0]] = (headersplit[1][:-1]).strip() + + length = int(self.headers.getheader('content-length')) + try: + message = json.loads(self.rfile.read(length)) + print("Got message: %s" % message) + ret = requests.post(url, headers=allheaders, json=message) + except: + message = self.rfile.read(length) + print("Got message: %s" % message) + ret = requests.post(url, headers=allheaders, data=message) + + print("RESP (%s) - %d - %s" % (url, ret.status_code, ret.text)) + + self.send_response(ret.status_code) + self.end_headers() + self.wfile.write(ret.text) + +httpd = SocketServer.ForkingTCPServer(('', PORT), MyProxy) +print("Now serving at %d" % PORT) +httpd.serve_forever() + diff --git a/functions/onprem/orborus/run.sh b/functions/onprem/orborus/run.sh index 48e5b701..eac60eec 100644 --- a/functions/onprem/orborus/run.sh +++ b/functions/onprem/orborus/run.sh @@ -1,9 +1,10 @@ docker run \ - --env ORG_ID=$ORG_ID \ + --env DOCKER_API_VERSION=1.40 \ --env ENVIRONMENT_NAME="Shuffle" \ - --env BASE_URL=http://shuffle-backend:5001 \ - --env DOCKER_API_VERSION=1.42 \ - --env RUNNING_MODE="Docker" \ - --network "shuffle_shuffle" \ + --env BASE_URL="http://192.168.86.45:5001" \ + --env HTTP_PROXY="http://192.168.86.45:8082" \ + --env HTTPS_PROXY="https://192.168.86.45:8082" \ + --env SHUFFLE_PASS_WORKER_PROXY=true \ + --env SHUFFLE_PASS_APP_PROXY=true \ -v /var/run/docker.sock:/var/run/docker.sock \ - frikky/shuffle:orborus + ghcr.io/frikky/shuffle-orborus:nightly