OXYGENHUB
◆ main oxygenflow / images / rust / build.sh
2.5 KiB · Bourne Again Shell (bash) · executable · last changed flow deps check: is every crate of a Cargo.lock in the image (closes #101) 1 day ago source blame history raw
1
#!/bin/sh
2
# Build the OxygenFlow build image and write it as a root file system
3
# tarball for `flow rootfs import`. Run from any directory; the Oxygen
4
# projects are expected next to this repository (../oxygen, ../oxygenhub).
5
# Rebuild whenever a Cargo.lock or package-lock.json of those projects changes.
6
set -eu
7
here=$(cd "$(dirname "$0")" && pwd)
8
dev=$(cd "$here/../../.." && pwd)
9
out=${1:-$here/oxygenflow-build.tar}
10
NODE_VERSION=24.21.0
11
NODE_SHA256=fd8e59d5a511510f6a298afb548f18c7d2b1be404d8b4a27d94fbe49f56cb2d6
12
ZIG_VERSION=0.16.0
13
ZIG_SHA256=70e49664a74374b48b51e6f3fdfbf437f6395d42509050588bd49abe52ba3d00
14
15
rm -rf "$here/vendor"
16
cargo vendor --locked --versioned-dirs \
17
    --manifest-path "$dev/oxygen/Cargo.toml" \
18
    --sync "$dev/oxygenhub/Cargo.toml" \
19
    --sync "$dev/oxygenflow/Cargo.toml" \
20
    "$here/vendor" >/dev/null
21
# The image's crates as `NAME VERSION` lines (#101): at /opt/crates.txt in
22
# the image and beside the tarball, for `flow deps check --list` to read.
23
for m in "$here"/vendor/*/Cargo.toml; do
24
    awk -F'"' '/^\[package\]/{p=1;next} /^\[/{p=0} p&&/^name = /{n=$2} p&&/^version = /{v=$2} END{print n" "v}' "$m"
25
done | sort > "$here/crates.txt"
26
# npm packages of the two extensions, into a cache `npm ci --offline` reads.
27
rm -rf "${here:?}/npm-cache"
28
for e in oxygen-vscode oxygenhub-vscode; do
29
    tmp=$(mktemp -d)
30
    cp "$dev/$e/package.json" "$dev/$e/package-lock.json" "$tmp/"
31
    (cd "$tmp" && npm ci --cache "$here/npm-cache" --ignore-scripts --no-audit --no-fund >/dev/null)
32
    rm -rf "${tmp:?}"
33
done
34
rm -rf "${here:?}/npm-cache/_logs"
35
# Dependency recipes of the workspaces whose dependencies the image
36
# prebuilds (see the Dockerfile).
37
rm -rf "${here:?}/warm"
38
for ws in oxygenhub oxygen oxygenflow; do
39
    python3 "$here/recipe.py" "$dev/$ws" "$here/warm/$ws"
40
done
41
# Readable by any user: a job runs as its workspace's owner on the runner
42
# host, which differs between runners (oxygen#59: 0640 files from Earth's
43
# umask failed plex's dist job).
44
chmod -R a+rX "$here/vendor" "$here/npm-cache" "$here/warm" "$here/crates.txt"
45
docker build -q -t oxygenflow-build \
46
    --build-arg NODE_VERSION=$NODE_VERSION --build-arg NODE_SHA256=$NODE_SHA256 \
47
    --build-arg ZIG_VERSION=$ZIG_VERSION --build-arg ZIG_SHA256=$ZIG_SHA256 "$here"
48
id=$(docker create oxygenflow-build)
49
docker export "$id" -o "$out"
50
docker rm "$id" >/dev/null
51
cp "$here/crates.txt" "${out%.tar}.crates.txt"
52
rm -rf "${here:?}/vendor" "${here:?}/npm-cache" "${here:?}/warm" "${here:?}/crates.txt"
53
echo "$out"