mirror of https://github.com/kubeflow/examples.git
Upgrade JS app to be served at any path prefix
This commit is contained in:
parent
9ce23d9fc6
commit
6527aba7c1
|
|
@ -16,6 +16,10 @@ ADD src/ /src
|
|||
|
||||
WORKDIR /src
|
||||
|
||||
ARG PUBLIC_URL
|
||||
|
||||
ENV PUBLIC_URL=$PUBLIC_URL
|
||||
|
||||
RUN cd ui && npm i && npm run build && cd ..
|
||||
|
||||
EXPOSE 8008
|
||||
|
|
|
|||
|
|
@ -5,18 +5,27 @@
|
|||
# the Code Search UI to Google Container Registry. It automatically tags
|
||||
# a unique image for every run.
|
||||
#
|
||||
# Also note the PUBLIC_URL endpoint which can either be an FQDN or a path
|
||||
# prefix to be used for the JS files in the React Application. It defaults
|
||||
# to "/code-search" which means the search server will be accessible at
|
||||
# https://PUBLIC_HOSTNAME/code-search.
|
||||
#
|
||||
|
||||
set -ex
|
||||
|
||||
BUILD_IMAGE_UUID=$(python3 -c 'import uuid; print(uuid.uuid4().hex[:7]);')
|
||||
BUILD_IMAGE_TAG="code-search-ui:v$(date +%Y%m%d)-${BUILD_IMAGE_UUID}"
|
||||
PUBLIC_URL=${PUBLIC_URL:-"/code-search"}
|
||||
|
||||
# Directory of this script used for path references
|
||||
_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
pushd "${_SCRIPT_DIR}"
|
||||
|
||||
docker build -f "${_SCRIPT_DIR}/Dockerfile" -t ${BUILD_IMAGE_TAG} "${_SCRIPT_DIR}/../.."
|
||||
docker build -f "${_SCRIPT_DIR}/Dockerfile" \
|
||||
-t ${BUILD_IMAGE_TAG} \
|
||||
--build-arg PUBLIC_URL=${PUBLIC_URL} \
|
||||
"${_SCRIPT_DIR}/../.."
|
||||
|
||||
# Push image to GCR PROJECT available
|
||||
PROJECT=${PROJECT:-}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@
|
|||
|
||||
"nmslib": {
|
||||
replicas: 1,
|
||||
image: "gcr.io/kubeflow-dev/code-search-ui:v20180803-156710e",
|
||||
image: "gcr.io/kubeflow-dev/code-search-ui:v20180806-7b0fcaa",
|
||||
|
||||
problem: "null",
|
||||
dataDir: "null",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
from flask import Flask, request, abort, jsonify, make_response, redirect
|
||||
|
||||
|
||||
|
|
@ -29,7 +30,8 @@ class CodeSearchServer:
|
|||
|
||||
@self.app.route('/')
|
||||
def index():
|
||||
return redirect('/index.html', code=302)
|
||||
redirect_path = os.environ.get('PUBLIC_URL', '') + '/index.html'
|
||||
return redirect(redirect_path, code=302)
|
||||
|
||||
@self.app.route('/ping')
|
||||
def ping():
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import request from 'superagent';
|
||||
|
||||
const SEARCH_URL='/query';
|
||||
const SEARCH_URL=`${process.env.PUBLIC_URL}/query`;
|
||||
|
||||
function code_search_api(str) {
|
||||
return request.get(SEARCH_URL).query({'q': str});
|
||||
|
|
|
|||
Loading…
Reference in New Issue