64 lines
2 KiB
FSharp
64 lines
2 KiB
FSharp
#load "projects.fsx"
|
|
#load "image.fsx"
|
|
|
|
open System
|
|
open System.IO
|
|
open Contract
|
|
open Image
|
|
open Projects
|
|
|
|
let revision = Environment.GetEnvironmentVariable "SOURCE_REVISION"
|
|
let project = Environment.GetEnvironmentVariable "TARGETS" |> decode<Target array> |> selectProject
|
|
let source = "/source/repository/services/mail-keys"
|
|
let working = directory "/output/working"
|
|
|
|
for path in Directory.EnumerateFiles(source, "*", SearchOption.AllDirectories) do
|
|
let target = Path.Combine(working, Path.GetRelativePath(source, path))
|
|
directory (Path.GetDirectoryName target) |> ignore
|
|
File.Copy(path, target)
|
|
|
|
let environment =
|
|
[ "HOME", "/tmp"; "PATH", "/toolchain/node/bin:/toolchain/usr/bin:/usr/bin:/bin"
|
|
"LD_LIBRARY_PATH", "/toolchain/usr/lib"; "npm_config_cache", "/tmp/npm" ]
|
|
|
|
requireSuccess
|
|
"/toolchain/usr/bin/busybox"
|
|
[ "cp"; "-a"; "/toolchain/frontend/node_modules"; Path.Combine(working, "node_modules") ]
|
|
None
|
|
environment
|
|
|> ignore
|
|
|
|
let checks =
|
|
Directory.EnumerateFiles(Path.Combine(working, "src"), "*.test.ts")
|
|
|> Seq.map (fun path -> Path.GetRelativePath(working, path))
|
|
|> Seq.toList
|
|
|
|
for arguments in
|
|
[ "--test" :: "--test-isolation=none" :: checks
|
|
[ "node_modules/typescript/bin/tsc"; "--noEmit" ]
|
|
[ "node_modules/vite/bin/vite.js"; "build" ] ] do
|
|
requireSuccess
|
|
"/toolchain/node/bin/node"
|
|
arguments
|
|
(Some working)
|
|
environment
|
|
|> ignore
|
|
|
|
let files _ =
|
|
let dist = Path.Combine(working, "dist")
|
|
|
|
(Directory.EnumerateFiles(dist, "*", SearchOption.AllDirectories)
|
|
|> Seq.map (fun path -> Path.Combine("usr/share/nginx/html/account", Path.GetRelativePath(dist, path)), path)
|
|
|> Seq.toList)
|
|
@ [ "etc/nginx/nginx.conf", "/orchestration/nginx.conf" ]
|
|
|
|
let digest =
|
|
assemble
|
|
"/toolchain/image-base"
|
|
"/output"
|
|
revision
|
|
[ "nginx"; "-g"; "daemon off;" ]
|
|
"/"
|
|
files
|
|
|
|
printfn "build=image project=%s digest=%s" project.Name digest
|