#!/bin/sh # Build the OxygenFlow build image and write it as a root file system # tarball for `flow rootfs import`. Run from any directory; the Oxygen # projects are expected next to this repository (../oxygen, ../oxygenhub). # Rebuild whenever a Cargo.lock or package-lock.json of those projects changes. set -eu here=$(cd "$(dirname "$0")" && pwd) dev=$(cd "$here/../../.." && pwd) out=${1:-$here/oxygenflow-build.tar} NODE_VERSION=24.21.0 NODE_SHA256=fd8e59d5a511510f6a298afb548f18c7d2b1be404d8b4a27d94fbe49f56cb2d6 ZIG_VERSION=0.16.0 ZIG_SHA256=70e49664a74374b48b51e6f3fdfbf437f6395d42509050588bd49abe52ba3d00 rm -rf "$here/vendor" cargo vendor --locked --versioned-dirs \ --manifest-path "$dev/oxygen/Cargo.toml" \ --sync "$dev/oxygenhub/Cargo.toml" \ --sync "$dev/oxygenflow/Cargo.toml" \ "$here/vendor" >/dev/null # npm packages of the two extensions, into a cache `npm ci --offline` reads. rm -rf "${here:?}/npm-cache" for e in oxygen-vscode oxygenhub-vscode; do tmp=$(mktemp -d) cp "$dev/$e/package.json" "$dev/$e/package-lock.json" "$tmp/" (cd "$tmp" && npm ci --cache "$here/npm-cache" --ignore-scripts --no-audit --no-fund >/dev/null) rm -rf "${tmp:?}" done rm -rf "${here:?}/npm-cache/_logs" # Dependency recipes of the workspaces whose dependencies the image # prebuilds (see the Dockerfile). rm -rf "${here:?}/warm" for ws in oxygenhub oxygen oxygenflow; do python3 "$here/recipe.py" "$dev/$ws" "$here/warm/$ws" done # Readable by any user: a job runs as its workspace's owner on the runner # host, which differs between runners (oxygen#59: 0640 files from Earth's # umask failed plex's dist job). chmod -R a+rX "$here/vendor" "$here/npm-cache" "$here/warm" docker build -q -t oxygenflow-build \ --build-arg NODE_VERSION=$NODE_VERSION --build-arg NODE_SHA256=$NODE_SHA256 \ --build-arg ZIG_VERSION=$ZIG_VERSION --build-arg ZIG_SHA256=$ZIG_SHA256 "$here" id=$(docker create oxygenflow-build) docker export "$id" -o "$out" docker rm "$id" >/dev/null rm -rf "${here:?}/vendor" "${here:?}/npm-cache" "${here:?}/warm" echo "$out"