-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.fsx
executable file
·174 lines (134 loc) · 5.5 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
#r "paket:
version 5.241.6
framework: netstandard20
source https://api.nuget.org/v3/index.json
nuget Be.Vlaanderen.Basisregisters.Build.Pipeline 3.3.1 //"
#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.JavaScript
open ``Build-generic``
// The buildserver passes in `BITBUCKET_BUILD_NUMBER` as an integer to version the results
// and `BUILD_DOCKER_REGISTRY` to point to a Docker registry to push the resulting Docker images.
// NpmInstall
// Run an `npm install` to setup Commitizen and Semantic Release.
// DotNetCli
// Checks if the requested .NET Core SDK and runtime version defined in global.json are available.
// We are pedantic about these being the exact versions to have identical builds everywhere.
// Clean
// Make sure we have a clean build directory to start with.
// Restore
// Restore dependencies for debian.8-x64 and win10-x64 using dotnet restore and Paket.
// Build
// Builds the solution in Release mode with the .NET Core SDK and runtime specified in global.json
// It builds it platform-neutral, debian.8-x64 and win10-x64 version.
// Test
// Runs `dotnet test` against the test projects.
// Publish
// Runs a `dotnet publish` for the debian.8-x64 and win10-x64 version as a self-contained application.
// It does this using the Release configuration.
// Pack
// Packs the solution using Paket in Release mode and places the result in the dist folder.
// This is usually used to build documentation NuGet packages.
// Containerize
// Executes a `docker build` to package the application as a docker image. It does not use a Docker cache.
// The result is tagged as latest and with the current version number.
// DockerLogin
// Executes `ci-docker-login.sh`, which does an aws ecr login to login to Amazon Elastic Container Registry.
// This uses the local aws settings, make sure they are working!
// Push
// Executes `docker push` to push the built images to the registry.
let product = "Basisregisters Vlaanderen"
let copyright = "Copyright (c) Vlaamse overheid"
let company = "Vlaamse overheid"
let dockerRepository = "public-service-registry"
let assemblyVersionNumber = (sprintf "2.%s")
let nugetVersionNumber = (sprintf "%s")
let build = buildSolution assemblyVersionNumber
let setVersions = (setSolutionVersions assemblyVersionNumber product copyright company)
let test = testSolution
let publish = publish assemblyVersionNumber
let pack = pack nugetVersionNumber
let containerize = containerize dockerRepository
let push = push dockerRepository
Target.create "CleanAll" (fun _ ->
Shell.cleanDir buildDir
Shell.cleanDir ("src" @@ "PublicServiceRegistry.UI" @@ "wwwroot")
)
// Solution -----------------------------------------------------------------------
Target.create "Restore_Solution" (fun _ -> restore "PublicServiceRegistry")
Target.create "Build_Solution" (fun _ ->
setVersions "SolutionInfo.cs"
build "PublicServiceRegistry")
Target.create "Site_Build" (fun _ ->
Npm.exec "build" id
let dist = (buildDir @@ "PublicServiceRegistry.UI" @@ "linux")
let source = "src" @@ "PublicServiceRegistry.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 "Test_Solution" (fun _ -> test "PublicServiceRegistry")
Target.create "Publish_Solution" (fun _ ->
[
"PublicServiceRegistry.Api.Backoffice"
"PublicServiceRegistry.Projector"
"PublicServiceRegistry.Projections.Backoffice"
"PublicServiceRegistry.OrafinUpload"
] |> List.iter publish)
Target.create "Pack_Solution" (fun _ ->
[
"PublicServiceRegistry.Api.Backoffice"
] |> List.iter pack)
Target.create "Containerize_ApiBackoffice" (fun _ -> containerize "PublicServiceRegistry.Api.Backoffice" "api")
Target.create "PushContainer_ApiBackoffice" (fun _ -> push "api")
Target.create "Containerize_Projections" (fun _ -> containerize "PublicServiceRegistry.Projector" "projector")
Target.create "PushContainer_Projections" (fun _ -> push "projector")
Target.create "Containerize_OrafinUpload" (fun _ -> containerize "PublicServiceRegistry.OrafinUpload" "batch-orafin")
Target.create "PushContainer_OrafinUpload" (fun _ -> push "batch-orafin")
Target.create "Containerize_Site" (fun _ -> containerize "PublicServiceRegistry.UI" "ui")
Target.create "PushContainer_Site" (fun _ -> push "ui")
// --------------------------------------------------------------------------------
Target.create "Build" ignore
Target.create "Test" ignore
Target.create "Publish" ignore
Target.create "Pack" ignore
Target.create "Containerize" ignore
Target.create "Push" ignore
"NpmInstall"
// ==> "DotNetCli"
==> "CleanAll"
==> "Restore_Solution"
==> "Build_Solution"
==> "Build"
"Build"
==> "Site_Build"
==> "Test_Solution"
==> "Test"
"Test"
==> "Publish_Solution"
==> "Publish"
"Publish"
==> "Pack_Solution"
==> "Pack"
"Pack"
==> "Containerize_ApiBackoffice"
==> "Containerize_Projections"
==> "Containerize_OrafinUpload"
==> "Containerize_Site"
==> "Containerize"
// Possibly add more projects to containerize here
"Containerize"
==> "DockerLogin"
==> "PushContainer_ApiBackoffice"
==> "PushContainer_Projections"
==> "PushContainer_OrafinUpload"
==> "PushContainer_Site"
==> "Push"
// Possibly add more projects to push here
// By default we build & test
Target.runOrDefault "Test"