-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathBuild.fs
112 lines (87 loc) · 3.13 KB
/
Build.fs
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
open Fake.Core
open Fake.IO
open Farmer
open Farmer.Builders
open Farmer.WebApp
open Helpers
initializeContext ()
let sharedPath = Path.getFullName "src/Shared"
let serverPath = Path.getFullName "src/Server"
let clientPath = Path.getFullName "src/Client"
let deployPath = Path.getFullName "deploy"
let sharedTestsPath = Path.getFullName "tests/Shared"
let serverTestsPath = Path.getFullName "tests/Server"
let clientTestsPath = Path.getFullName "tests/Client"
let appName = "safebookstore"
let storageAccountName = $"{appName}storage"
let logAnalyticsName = $"{appName}-la"
let appInsightsName = $"{appName}-ai"
Target.create "Clean" (fun _ ->
Shell.cleanDir deployPath
run dotnet [ "fable"; "clean"; "--yes" ] clientPath // Delete *.fs.js files created by Fable
)
Target.create "InstallClient" (fun _ -> run npm [ "install" ] ".")
Target.create "StartServices" (fun _ ->
async {
runParallel [
"Docker Services", docker [ "compose"; "--project-name"; "bookstore"; "up" ] "."
]
}
|> Async.Start)
Target.create "Bundle" (fun _ ->
[
"server", dotnet [ "publish"; "-c"; "Release"; "-o"; deployPath ] serverPath
"client", dotnet [ "fable"; "-o"; "output"; "-s"; "--run"; "npx"; "vite"; "build" ] clientPath
]
|> runParallel)
Target.create "Azure" (fun _ ->
let analytics = logAnalytics { name logAnalyticsName }
let insights = appInsights {
name appInsightsName
log_analytics_workspace analytics
}
let web = webApp {
name appName
system_identity
setting "StorageAccountName" storageAccountName
operating_system OS.Linux
runtime_stack Runtime.DotNet80
sku (Basic "B1")
zip_deploy "deploy"
always_on
link_to_app_insights insights
}
let storage = storageAccount {
name storageAccountName
grant_access web.SystemIdentity Roles.StorageTableDataContributor
grant_access web.SystemIdentity Roles.StorageBlobDataContributor
}
let deployment = arm {
location Location.WestEurope
add_resources [ web; storage; analytics; insights ]
}
deployment |> Deploy.execute appName Deploy.NoParameters |> ignore)
Target.create "Run" (fun _ ->
run dotnet [ "build" ] sharedPath
[
"server", dotnet [ "watch"; "run" ] serverPath
"client", dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "--run"; "npx"; "vite" ] clientPath
]
|> runParallel)
Target.create "Tests" (fun _ ->
run dotnet [ "build" ] sharedTestsPath
[
"server", dotnet [ "watch"; "run" ] serverTestsPath
"client", dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "--run"; "npx"; "vite" ] clientTestsPath
]
|> runParallel)
Target.create "DevOpsTests" (fun _ -> run dotnet [ "run"; "-c"; "release"; "-l"; "trx" ] serverTestsPath)
Target.create "Format" (fun _ -> run dotnet [ "fantomas"; "." ] ".")
open Fake.Core.TargetOperators
let dependencies = [
"Clean" ==> "InstallClient" ==> "Bundle"
"Clean" ==> "InstallClient" ==> "StartServices" ==> "Run"
"InstallClient" ==> "Tests"
]
[<EntryPoint>]
let main args = runOrDefault args