Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
143 lines (128 loc) · 7.66 KB
/
Copy pathTaskfile.yml
File metadata and controls
143 lines (128 loc) · 7.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: '3'
vars:
BUILD_DIR: build
# Shared execve shim every non-Node backend zips in as index.js.
NODE_WRAPPER: src/node-wrapper/index.js
# Web Functions are arm64 only (Graviton).
GOOS: linux
GOARCH: arm64
tasks:
format:
desc: Format files in the repository
cmd: format files $(git ls-files -co --exclude-standard)
build:
desc: Build every app artifact into build/
deps:
- build:node-api
- build:go-api
- build:dotnet-api
- build:dotnet-aot-api
- build:blazor
- build:blazor-aot
- build:python-api
- build:java-api
- build:java-aot-api
- build:kotlin-api
build:node-api:
desc: Bundle the Node API into build/node-api.zip
dir: src/node-api
cmds:
- npm run build
- mkdir -p '{{.ROOT_DIR}}/{{.BUILD_DIR}}'
- rm -f '{{.ROOT_DIR}}/{{.BUILD_DIR}}/node-api.zip'
- cd dist && zip -qr '{{.ROOT_DIR}}/{{.BUILD_DIR}}/node-api.zip' .
build:go-api:
desc: Cross-compile and bundle the Go API into build/go-api.zip
dir: src/go-api
cmds:
# Build the binary into build/ and zip it flat with the shared wrapper, so
# no staging copy of either is left in build/.
- mkdir -p '{{.ROOT_DIR}}/{{.BUILD_DIR}}'
- CGO_ENABLED=0 GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -trimpath -o '{{.ROOT_DIR}}/{{.BUILD_DIR}}/server' .
- rm -f '{{.ROOT_DIR}}/{{.BUILD_DIR}}/go-api.zip'
# zip -j jams paths, so the wrapper lands in the zip root as index.js.
- zip -jq '{{.ROOT_DIR}}/{{.BUILD_DIR}}/go-api.zip' '{{.ROOT_DIR}}/{{.NODE_WRAPPER}}' '{{.ROOT_DIR}}/{{.BUILD_DIR}}/server'
- rm -f '{{.ROOT_DIR}}/{{.BUILD_DIR}}/server'
build:dotnet-api:
desc: Build the non-AOT ASP.NET API (self-contained, reflection-enabled) into build/dotnet-api.zip
cmds:
# Reflection means no trimming and no NativeAOT, so the zip carries the
# whole .NET runtime; everything -- publish, smoke, packaging -- happens
# on linux/arm64 inside src/DotnetApi/Dockerfile and only the zip comes
# back out.
- rm -f '{{.ROOT_DIR}}/{{.BUILD_DIR}}/dotnet-api.zip'
- docker buildx build --platform linux/arm64 --target export --output 'type=local,dest={{.ROOT_DIR}}/{{.BUILD_DIR}}' -f '{{.ROOT_DIR}}/src/DotnetApi/Dockerfile' '{{.ROOT_DIR}}'
build:dotnet-aot-api:
desc: Publish the ASP.NET NativeAOT API and bundle it into build/dotnet-aot-api.zip
cmds:
# NativeAOT can't link a linux-arm64 binary on macOS (no Linux sysroot),
# so the publish runs in a linux/arm64 SDK container. AssemblyName=server
# so the native binary matches the wrapper's contract.
- rm -rf '{{.ROOT_DIR}}/{{.BUILD_DIR}}/dotnet-aot-api'
- mkdir -p '{{.ROOT_DIR}}/{{.BUILD_DIR}}/dotnet-aot-api'
- docker build --platform linux/arm64 -q -t dotnet-aot-api -f '{{.ROOT_DIR}}/src/DotnetApiAot/Dockerfile.aot' '{{.ROOT_DIR}}/src/DotnetApiAot'
- docker run --rm --platform linux/arm64 -u "$(id -u):$(id -g)" -e HOME=/tmp -v '{{.ROOT_DIR}}:/work' -w /work dotnet-aot-api dotnet publish src/DotnetApiAot/DotnetApiAot.csproj -c Release -r {{.GOOS}}-{{.GOARCH}} -p:AssemblyName=server -o build/dotnet-aot-api --nologo
- rm -f '{{.ROOT_DIR}}/{{.BUILD_DIR}}/dotnet-aot-api.zip'
- zip -jq '{{.ROOT_DIR}}/{{.BUILD_DIR}}/dotnet-aot-api.zip' '{{.ROOT_DIR}}/{{.NODE_WRAPPER}}' '{{.ROOT_DIR}}/{{.BUILD_DIR}}/dotnet-aot-api/server' '{{.ROOT_DIR}}/{{.BUILD_DIR}}/dotnet-aot-api/appsettings.json'
- rm -rf '{{.ROOT_DIR}}/{{.BUILD_DIR}}/dotnet-aot-api'
build:blazor:
desc: Build the Blazor Web App (interpreted WebAssembly) into build/blazor-web.zip
cmds:
# One app, two projects, two build tasks: AOT is a publish property, not
# different code, so the AOT variant below is the same source with the
# flag flipped. The server is a self-contained linux-arm64 publish either
# way; only the WebAssembly client bundle differs. Needs Docker and
# network access (the build installs the wasm-tools workload).
- rm -f '{{.ROOT_DIR}}/{{.BUILD_DIR}}/blazor-web.zip'
- docker buildx build --platform linux/arm64 --target export --output 'type=local,dest={{.ROOT_DIR}}/{{.BUILD_DIR}}' --build-arg ZIP_NAME=blazor-web.zip -f '{{.ROOT_DIR}}/src/blazor/BlazorApp/Dockerfile' '{{.ROOT_DIR}}'
build:blazor-aot:
desc: Build the Blazor Web App (AOT-compiled WebAssembly) into build/blazor-aot-web.zip
cmds:
# RunAOTCompilation + WasmStripILAfterAOT: a much larger client bundle for
# faster execution in the browser. Same server, same source.
- rm -f '{{.ROOT_DIR}}/{{.BUILD_DIR}}/blazor-aot-web.zip'
- docker buildx build --platform linux/arm64 --target export --output 'type=local,dest={{.ROOT_DIR}}/{{.BUILD_DIR}}' --build-arg ZIP_NAME=blazor-aot-web.zip --build-arg AOT=true --build-arg STRIP_IL=true -f '{{.ROOT_DIR}}/src/blazor/BlazorApp/Dockerfile' '{{.ROOT_DIR}}'
build:python-api:
desc: Build FastAPI + a bundled CPython into build/python-api.zip (needs Docker)
cmds:
# Web Functions ship no Python, so unlike Go and the .NET AOT build
# (single static binaries) this zip carries the whole interpreter next to
# it -- interpreter download, locked deps, tests, packaging -- happens on
# linux/arm64 inside src/python-api/Dockerfile, so there is no
# cross-platform resolution to do on the host. The export stage copies out
# just the finished zip.
- rm -f '{{.ROOT_DIR}}/{{.BUILD_DIR}}/python-api.zip'
- docker buildx build --platform linux/arm64 --target export --output 'type=local,dest={{.ROOT_DIR}}/{{.BUILD_DIR}}' -f '{{.ROOT_DIR}}/src/python-api/Dockerfile' '{{.ROOT_DIR}}'
build:java-api:
desc: Build the Spring Boot backend on the JVM into build/java-api.zip (needs Docker)
cmds:
# Like the Python and managed-.NET builds, everything -- Maven, the
# jlink'd JRE, the smoke, the packaging -- happens on linux/arm64 inside
# src/java-api/Dockerfile and only the finished zip comes back out.
# src/java-api is built twice; build:java-aot-api is the same source.
- rm -f '{{.ROOT_DIR}}/{{.BUILD_DIR}}/java-api.zip'
- docker buildx build --platform linux/arm64 --target export --output 'type=local,dest={{.ROOT_DIR}}/{{.BUILD_DIR}}' -f '{{.ROOT_DIR}}/src/java-api/Dockerfile' '{{.ROOT_DIR}}'
build:java-aot-api:
desc: Build the same backend with GraalVM native-image into build/java-aot-api.zip (needs Docker)
cmds:
# The other build of src/java-api: identical source, compiled ahead of
# time instead of run on a JVM. native-image needs the GraalVM toolchain
# and a Linux C toolchain, so it runs in GraalVM's own linux/arm64 image.
# The -ol9 tag is load-bearing twice over: it pins the binary's glibc
# requirement to 2.34, which is what the Web Function environment ships,
# and Spring Boot 4 refuses to start a native image built below Java 25.
- rm -f '{{.ROOT_DIR}}/{{.BUILD_DIR}}/java-aot-api.zip'
- docker buildx build --platform linux/arm64 --target export --output 'type=local,dest={{.ROOT_DIR}}/{{.BUILD_DIR}}' -f '{{.ROOT_DIR}}/src/java-api/Dockerfile.aot' '{{.ROOT_DIR}}'
build:kotlin-api:
desc: Build the Kotlin/Ktor backend into build/kotlin-api.zip (needs Docker)
cmds:
- rm -f '{{.ROOT_DIR}}/{{.BUILD_DIR}}/kotlin-api.zip'
- docker buildx build --platform linux/arm64 --target export --output 'type=local,dest={{.ROOT_DIR}}/{{.BUILD_DIR}}' -f '{{.ROOT_DIR}}/src/kotlin-api/Dockerfile' '{{.ROOT_DIR}}'
deploy:
desc: Deploy the CDK stack (builds artifacts first). Extra args via `task deploy -- ...`
dir: infra
deps:
- build
cmds:
- npx cdk deploy {{.CLI_ARGS}}