20846: Fix workbench2 build recipe.
authorTom Clegg <tom@curii.com>
Thu, 26 Oct 2023 15:23:43 +0000 (11:23 -0400)
committerTom Clegg <tom@curii.com>
Fri, 3 Nov 2023 20:00:11 +0000 (16:00 -0400)
Install recipe was failing on readonly source tree, e.g., mounted into
a docker container by `arvados-package build`.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

lib/install/deps.go

index 0d238d06faeea01d038af3217740496a6690b5a9..3784cf6a186fbef42e38b8f048b321fb6b86c3fc 100644 (file)
@@ -677,11 +677,24 @@ done
                        return 1
                }
 
-               // Install workbench2 app to /var/lib/arvados/workbench2/
+               // Install workbench2 app to
+               // /var/lib/arvados/workbench2/.
+               //
+               // We copy the source tree from the (possibly
+               // readonly) source tree into a temp dir because `yarn
+               // build` writes to {source-tree}/build/. When we
+               // upgrade to react-scripts >= 4.0.2 we may be able to
+               // build from the source dir and write directly to the
+               // final destination (using
+               // YARN_INSTALL_STATE_PATH=/dev/null
+               // BUILD_PATH=/var/lib/arvados/workbench2) instead of
+               // using two rsync steps here.
                if err = inst.runBash(`
-cd `+inst.SourcePath+`/services/workbench2
-VERSION="`+inst.PackageVersion+`" BUILD_NUMBER=1 GIT_COMMIT=000000000 yarn build
-rsync -a --delete-after build/ /var/lib/arvados/workbench2/
+tmp=/var/lib/arvados/tmp/workbench2
+trap "rm -r ${tmp}" ERR EXIT
+rsync -a --delete-after `+inst.SourcePath+`/services/workbench2/ "$tmp/"
+env -C "$tmp" VERSION="`+inst.PackageVersion+`" BUILD_NUMBER=1 GIT_COMMIT=000000000 yarn build
+rsync -a --delete-after "$tmp/build/" /var/lib/arvados/workbench2/
 `, stdout, stderr); err != nil {
                        return 1
                }