19077: yarn is already installed
[arvados.git] / tools / arvbox / lib / arvbox / docker / service / workbench2 / run-service
index 1aef132799759e7a615d636d6e3d5d2cb78391bf..2b68cadafde7514383cf7e0b3a5d09b0a9a638c3 100755 (executable)
@@ -8,9 +8,13 @@ set -ex -o pipefail
 
 .  /usr/local/lib/arvbox/common.sh
 
-cd /usr/src/workbench2
+if test "$1" != "--only-deps" ; then
+  while [ ! -f $ARVADOS_CONTAINER_PATH/api.ready ]; do
+    sleep 1
+  done
+fi
 
-npm -d install --prefix /usr/local --global yarn
+cd /usr/src/workbench2
 
 yarn install
 
@@ -18,6 +22,41 @@ if test "$1" = "--only-deps" ; then
     exit
 fi
 
-echo "{\"API_HOST\": \"${localip}:${services[controller-ssl]}\"}" > /usr/src/workbench2/public/config.json
+cat <<EOF > /usr/src/workbench2/public/config.json
+{
+  "API_HOST": "${localip}:${services[controller-ssl]}",
+  "VOCABULARY_URL": "/vocabulary-example.json",
+  "FILE_VIEWERS_CONFIG_URL": "/file-viewers-example.json"
+}
+EOF
+
+export ARVADOS_API_HOST=$localip:${services[controller-ssl]}
+export ARVADOS_API_TOKEN=$(cat $ARVADOS_CONTAINER_PATH/superuser_token)
+
+url_prefix="https://$localip:${services[workbench2-ssl]}/"
+
+set +e
+read -rd $'\000' apiclient <<EOF
+{
+   "url_prefix": "$url_prefix",
+   "is_trusted": true
+}
+EOF
+set -e
+
+clientuuid=$(arv --format=uuid api_client list --filters '[["url_prefix", "=", "'$url_prefix'"]]')
+if [[ -n "$clientuuid" ]] ; then
+    arv api_client update --uuid $clientuuid --api-client "$apiclient"
+else
+    arv api_client create --api-client "$apiclient"
+fi
+
+# Can't use "yarn start", need to run the dev server script
+# directly so that the TERM signal from "sv restart" gets to the
+# right process.
+export VERSION=$(./version-at-commit.sh)
+export BROWSER=none
+export CI=true
 export HTTPS=false
-exec yarn start
+node --version
+exec node node_modules/react-scripts/scripts/start.js