ce7cb702218693d08ea6d83464d2457c9250027c
This commit is contained in:
commit
34c5f8963c
1 changed files with 145336 additions and 0 deletions
|
|
@ -0,0 +1,78 @@
|
|||
#load "plan.fsx"
|
||||
|
||||
open System
|
||||
open System.Diagnostics
|
||||
open System.IO
|
||||
open System.Runtime.InteropServices
|
||||
open Contract
|
||||
open Plan
|
||||
|
||||
let plan = read ()
|
||||
let root = "/toolchain"
|
||||
let ready = Path.Combine(root, ".ready")
|
||||
let baseImage = Path.Combine(root, "image-base")
|
||||
|
||||
let environment =
|
||||
[ "GOCACHE", Path.Combine(root, "download-cache")
|
||||
"GOENV", "off"
|
||||
"GOMODCACHE", Path.Combine(root, "modules")
|
||||
"GOPATH", Path.Combine(root, "gopath")
|
||||
"GOPROXY", "https://proxy.golang.org"
|
||||
"GOROOT", Path.Combine(root, "usr/lib/go")
|
||||
"GOSUMDB", "sum.golang.org"
|
||||
"HOME", Path.Combine(root, "home") ]
|
||||
|
||||
match plan.Toolchain.Origin with
|
||||
| "cache" ->
|
||||
let elapsed = Stopwatch.StartNew()
|
||||
|
||||
while not (File.Exists ready) && elapsed.Elapsed < TimeSpan.FromMinutes 15.0 do
|
||||
sleep 100
|
||||
|
||||
require (File.Exists ready && File.Exists(Path.Combine(baseImage, "index.json"))) "cached toolchain unavailable"
|
||||
printfn "toolchain=cache"
|
||||
| "primary" ->
|
||||
require (RuntimeInformation.ProcessArchitecture = Architecture.X64) "unsupported toolchain architecture"
|
||||
|
||||
requireSuccess
|
||||
"/sbin/apk"
|
||||
[ "add"
|
||||
"--root"
|
||||
root
|
||||
"--arch"
|
||||
"x86_64"
|
||||
"--initdb"
|
||||
"--no-scripts"
|
||||
"--keys-dir"
|
||||
"/etc/apk/keys"
|
||||
"--repository"
|
||||
"https://packages.wolfi.dev/os"
|
||||
"ca-certificates-bundle=20261020-r0"
|
||||
"go-1.27=1.27.3-r0"
|
||||
"wolfi-baselayout=20230201-r30" ]
|
||||
None
|
||||
[]
|
||||
|> ignore
|
||||
|
||||
let go = Path.Combine(root, "usr/lib/go/bin/go")
|
||||
let source = "/source/repository/services/project-delivery/controller"
|
||||
directory (Path.Combine(root, "modules")) |> ignore
|
||||
requireSuccess go [ "mod"; "download" ] (Some source) environment |> ignore
|
||||
directory baseImage |> ignore
|
||||
|
||||
requireSuccess
|
||||
"/usr/bin/apko"
|
||||
[ "build"
|
||||
"--arch"
|
||||
"x86_64,arm64"
|
||||
"--sbom=false"
|
||||
"/orchestration/controller.apko.yaml"
|
||||
"controller:base"
|
||||
baseImage ]
|
||||
None
|
||||
environment
|
||||
|> ignore
|
||||
|
||||
File.WriteAllText(ready, plan.SourceRevision + "\n")
|
||||
printfn "toolchain=primary"
|
||||
| _ -> fail "invalid toolchain origin"
|
||||
Loading…
Reference in a new issue