-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.fsx
executable file
·264 lines (202 loc) · 8.83 KB
/
build.fsx
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#r "paket:
version 7.0.2
framework: net6.0
source https://api.nuget.org/v3/index.json
nuget Be.Vlaanderen.Basisregisters.Build.Pipeline 6.0.5 //"
#load "packages/Be.Vlaanderen.Basisregisters.Build.Pipeline/Content/build-generic.fsx"
open Fake.Core
open Fake.Core.TargetOperators
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.JavaScript
open Fake.DotNet
open ``Build-generic``
open System
open System.IO
let product = "Basisregisters Vlaanderen"
let copyright = "Copyright (c) Vlaamse overheid"
let company = "Vlaamse overheid"
let dockerRepository = "organisation-registry"
let assemblyVersionNumber = (sprintf "2.%s")
let nugetVersionNumber = (sprintf "%s")
let buildSolution = buildSolution assemblyVersionNumber
let buildSource = build assemblyVersionNumber
let buildTest = buildTest assemblyVersionNumber
let setVersions = (setSolutionVersions assemblyVersionNumber product copyright company)
let publishSource = publish assemblyVersionNumber
let pack = pack nugetVersionNumber
let containerize = containerize dockerRepository
let push = push dockerRepository
supportedRuntimeIdentifiers <- [ "linux-x64" ]
let testWithDotNet path =
let fxVersion = getDotNetClrVersionFromGlobalJson()
let cmd = sprintf "test --no-build --no-restore --logger trx --configuration Release --no-build --no-restore /p:RuntimeFrameworkVersion=%s --dcReportType=HTML" fxVersion
let result = DotNet.exec (id) "dotcover" cmd
if result.ExitCode <> 0 then failwith "Test Failure"
let test project =
testWithDotNet ("test" @@ project @@ (sprintf "%s.csproj" project))
let testSolution sln =
testWithDotNet (sprintf "%s.sln" sln)
Target.create "CleanAll" (fun _ ->
Shell.cleanDir buildDir
Shell.cleanDir ("src" @@ "OrganisationRegistry.UI" @@ "wwwroot")
)
// Solution -----------------------------------------------------------------------
Target.create "SetSolutionInfo" (fun _ ->
setVersions "SolutionInfo.cs"
)
Target.create "Restore_Solution" (fun _ -> restore "OrganisationRegistry")
Target.create "Build_Solution" (fun _ ->
setVersions "SolutionInfo.cs"
buildSolution "OrganisationRegistry")
Target.create "Build_AcmIdm" (fun _ ->
setVersions "SolutionInfo.cs"
buildSolution "src/IdentityServer/IdentityServer")
Target.create "Site_Build" (fun _ ->
Npm.exec "run build" id
let dist = (buildDir @@ "OrganisationRegistry.UI" @@ "linux")
let source = "src" @@ "OrganisationRegistry.UI"
Shell.copyDir (dist @@ "wwwroot") (source @@ "wwwroot") (fun _ -> true)
Shell.copyFile dist (source @@ "Dockerfile")
Shell.copyFile dist (source @@ "default.conf")
Shell.copyFile dist (source @@ "config.js")
Shell.copyFile dist (source @@ "init.sh")
()
)
Target.create "Vue_Build" (fun _ ->
let dist = (buildDir @@ "OrganisationRegistry.UI" @@ "linux")
let source = "src" @@ "OrganisationRegistry.UI"
Npm.install (fun o -> { o with WorkingDirectory = "src" @@ "OrganisationRegistry.Vue2" })
Npm.exec "run build" (fun o -> { o with WorkingDirectory = "src" @@ "OrganisationRegistry.Vue2" })
let vueDist = ("src" @@ "OrganisationRegistry.Vue2" @@ "dist")
Shell.mkdir (dist @@ "wwwroot" @@ "vue")
Shell.copyDir (dist @@ "wwwroot" @@ "vue") (vueDist) (fun _ -> true)
()
)
Target.create "Test_Solution" (fun _ -> testSolution "OrganisationRegistry")
Target.create "Publish_Solution" (fun _ ->
[
"OrganisationRegistry.Api"
"OrganisationRegistry.AgentschapZorgEnGezondheid.FtpDump"
"OrganisationRegistry.VlaanderenBeNotifier"
"OrganisationRegistry.ElasticSearch.Projections"
"OrganisationRegistry.Projections.Delegations"
"OrganisationRegistry.Projections.Reporting"
"OrganisationRegistry.KboMutations"
"OrganisationRegistry.Rebuilder"
] |> Seq.toArray
|> Array.Parallel.iter publishSource
)
Target.create "Publish_Api" (fun _ ->
publishSource "OrganisationRegistry.Api"
)
Target.create "Publish_AgentschapZorgEnGezondheid" (fun _ ->
publishSource "OrganisationRegistry.AgentschapZorgEnGezondheid.FtpDump"
)
Target.create "Publish_VlaanderenBeNotifier" (fun _ ->
publishSource "OrganisationRegistry.VlaanderenBeNotifier"
)
Target.create "Publish_ElasticSearch" (fun _ ->
publishSource "OrganisationRegistry.ElasticSearch.Projections"
)
Target.create "Publish_Delegations" (fun _ ->
publishSource "OrganisationRegistry.Projections.Delegations"
)
Target.create "Publish_OrganisationRegistry.Reporting" (fun _ ->
publishSource "OrganisationRegistry.Projections.Reporting"
)
Target.create "Publish_KboMutions" (fun _ ->
publishSource "OrganisationRegistry.KboMutations"
)
Target.create "Publish_Rebuilder" (fun _ ->
publishSource "OrganisationRegistry.Rebuilder"
)
Target.create "Clean_Solution" (fun _ ->
!! "src/**/obj/*" |> File.deleteAll
!! "src/**/bin/*" |> File.deleteAll
!! "packages/**/*" -- "packages/*Basisregisters*/**/*" |> File.deleteAll
)
Target.create "Pack_Solution" (fun _ ->
[
"OrganisationRegistry.Api"
] |> List.iter pack)
Target.create "Containerize_Api" (fun _ -> containerize "OrganisationRegistry.Api" "api")
Target.create "PushContainer_Api" (fun _ -> push "api")
Target.create "Containerize_AgentschapZorgEnGezondheid" (fun _ -> containerize "OrganisationRegistry.AgentschapZorgEnGezondheid.FtpDump" "batch-agentschapzorgengezondheidftpdump")
Target.create "PushContainer_AgentschapZorgEnGezondheid" (fun _ -> push "batch-agentschapzorgengezondheidftpdump")
Target.create "Containerize_VlaanderenBeNotifier" (fun _ -> containerize "OrganisationRegistry.VlaanderenBeNotifier" "batch-vlaanderenbe")
Target.create "PushContainer_VlaanderenBeNotifier" (fun _ -> push "batch-vlaanderenbe")
Target.create "Containerize_ElasticSearch" (fun _ -> containerize "OrganisationRegistry.ElasticSearch.Projections" "projections-elasticsearch")
Target.create "PushContainer_ElasticSearch" (fun _ -> push "projections-elasticsearch")
Target.create "Containerize_Delegations" (fun _ -> containerize "OrganisationRegistry.Projections.Delegations" "projections-delegations")
Target.create "PushContainer_Delegations" (fun _ -> push "projections-delegations")
Target.create "Containerize_Reporting" (fun _ -> containerize "OrganisationRegistry.Projections.Reporting" "projections-reporting")
Target.create "PushContainer_Reporting" (fun _ -> push "projections-reporting")
Target.create "Containerize_KboMutations" (fun _ -> containerize "OrganisationRegistry.KboMutations" "kbo-mutations")
Target.create "PushContainer_KboMutations" (fun _ -> push "kbo-mutations")
Target.create "Containerize_Rebuilder" (fun _ -> containerize "OrganisationRegistry.Rebuilder" "rebuilder")
Target.create "PushContainer_Rebuilder" (fun _ -> push "rebuilder")
Target.create "Containerize_Site" (fun _ -> containerize "OrganisationRegistry.UI" "ui")
Target.create "PushContainer_Site" (fun _ -> push "ui")
let containerizeAcmIdm path containerName =
let result1 =
[ "build"; "."; "--no-cache"; "--tag"; sprintf "%s/%s/%s:%s" dockerRegistry dockerRepository containerName buildNumber; "--build-arg"; sprintf "build_number=%s" buildNumber]
|> CreateProcess.fromRawCommand "docker"
|> CreateProcess.withWorkingDirectory (path)
|> CreateProcess.withTimeout (TimeSpan.FromMinutes 5.)
|> Proc.run
if result1.ExitCode <> 0 then failwith "Failed result from Docker Build"
let result2 =
[ "tag"; sprintf "%s/%s/%s:%s" dockerRegistry dockerRepository containerName buildNumber; sprintf "%s/%s/%s:latest" dockerRegistry dockerRepository containerName]
|> CreateProcess.fromRawCommand "docker"
|> CreateProcess.withTimeout (TimeSpan.FromMinutes 5.)
|> Proc.run
if result2.ExitCode <> 0 then failwith "Failed result from Docker Tag"
Target.create "Containerize_AcmIdm" (fun _ -> containerizeAcmIdm "src/IdentityServer" "acmidm")
Target.create "PushContainer_AcmIdm" (fun _ -> push "acmidm")
// --------------------------------------------------------------------------------
Target.create "Default" ignore
Target.create "Publish" ignore
Target.create "Pack" ignore
Target.create "Containerize" ignore
Target.create "Push" ignore
"Restore_Solution"
==> "Build_Solution"
==> "Default"
"Restore_Solution"
==> "Build_Solution"
==> "Test_Solution"
"Site_Build"
==> "Default"
"Vue_Build"
==> "Default"
"Restore_Solution"
==> "Build_AcmIdm"
==> "Containerize_AcmIdm"
"Default"
==> "Publish_Solution"
==> "Clean_Solution"
==> "Publish"
"Publish"
==> "Pack_Solution"
==> "Pack"
"Site_Build"
==> "Vue_Build"
==> "Containerize_Site"
"Containerize"
==> "DockerLogin"
==> "PushContainer_Api"
==> "PushContainer_AgentschapZorgEnGezondheid"
==> "PushContainer_VlaanderenBeNotifier"
==> "PushContainer_ElasticSearch"
==> "PushContainer_Delegations"
==> "PushContainer_Reporting"
==> "PushContainer_KboMutations"
==> "PushContainer_Rebuilder"
==> "PushContainer_Site"
==> "PushContainer_AcmIdm"
==> "Push"
Target.create "Containerize_All" ignore
// By default we build & test
Target.runOrDefault "Default"