#load "projects.fsx" open System open System.IO open System.Net.Http open System.Runtime.InteropServices open Contract open Projects let project = Environment.GetEnvironmentVariable "TARGETS" |> decode |> selectProject let architecture, nodeArch, digest = match RuntimeInformation.ProcessArchitecture with | Architecture.X64 -> "x86_64", "x64", "5848553868b402d3fabb5b09270649977780a390f832155721025a08b5104455" | Architecture.Arm64 -> "aarch64", "arm64", "439e9c438acdf6a6ffe47418da709153d66c4bed812e30a473faacb107dd2791" | _ -> fail "unsupported build architecture" if not (Handoff.primary "/state") then printfn "toolchain=cache" else requireSuccess "/sbin/apk" [ "add" "--root" "/toolchain" "--arch" architecture "--initdb" "--no-scripts" "--keys-dir" "/etc/apk/keys" "--repository" "https://packages.wolfi.dev/os" "busybox=1.38.0-r3" "glibc-2.43=2.43-r18" "ld-linux-2.43=2.43-r18" "libgcc=16.2.0-r1" "libstdc++=16.2.0-r1" ] None [] |> ignore let name = $"node-v26.13.0-linux-{nodeArch}" let archive = "/tmp/node.tar.gz" use client = new HttpClient(Timeout = TimeSpan.FromMinutes 5.0) use input = client .GetStreamAsync($"https://nodejs.org/dist/v26.13.0/{name}.tar.gz", cancellationToken) .GetAwaiter() .GetResult() do use output = File.Create archive input.CopyTo output require (sha256 archive = digest) "Node.js checksum mismatch" extractGzip archive "/toolchain" Directory.Move($"/toolchain/{name}", "/toolchain/node") File.Delete archive use npm = client .GetStreamAsync("https://registry.npmjs.org/npm/-/npm-12.2.1.tgz", cancellationToken) .GetAwaiter() .GetResult() do use output = File.Create archive npm.CopyTo output require (sha256 archive = "228bd64aaef23270dbdbd2cf3d5ef5c467602ef38c4066246cef1984adab9a67") "npm checksum mismatch" extractGzip archive (directory "/toolchain/npm") Directory.Delete("/toolchain/node/lib/node_modules/npm", true) Directory.Move("/toolchain/npm/package", "/toolchain/node/lib/node_modules/npm") File.Delete archive directory "/toolchain/frontend" |> ignore [ "package.json"; "package-lock.json" ] |> List.iter (fun name -> File.Copy($"/source/repository/services/mail-keys/{name}", $"/toolchain/frontend/{name}")) let environment = [ "HOME", "/tmp" "PATH", "/toolchain/node/bin:/usr/bin:/bin" "LD_LIBRARY_PATH", "/toolchain/usr/lib" "npm_config_cache", "/tmp/npm" ] requireSuccess "/toolchain/node/bin/node" [ "/toolchain/node/lib/node_modules/npm/bin/npm-cli.js" "ci" "--ignore-scripts" "--no-audit" "--no-fund" ] (Some "/toolchain/frontend") environment |> ignore directory "/toolchain/image-base" |> ignore requireSuccess "/usr/bin/apko" [ "build" "--arch" "x86_64,arm64" "--sbom=false" "/orchestration/go-oci.apko.yaml" "mail-keys:base" "/toolchain/image-base" ] None environment |> ignore printfn "toolchain=primary project=%s" project.Name