-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.fsx
More file actions
97 lines (78 loc) · 2.9 KB
/
build.fsx
File metadata and controls
97 lines (78 loc) · 2.9 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
open System
#r "paket:
nuget Fake.Core.Target prerelease
nuget Fake.IO.FileSystem
nuget Fake.DotNet.MsBuild
nuget Fake.DotNet.Cli
nuget Fake.Core.Globbing"
#load "./.fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.IO
open Fake.DotNet.Cli
open Fake.Core.Globbing.Operators
let solutionFile = "./SentimentFS.AnalysisServer.sln"
let dockerComposeFileName = "docker-compose.yml"
let dockerProjects = [ "./src/SentimentService/SentimentService.fsproj"; "./src/TweetsService/TweetsService.fsproj"; "./src/WebApi/WebApi.fsproj" ]
let dockerImages = ["sentimentfs.webapi"; "sentimentfs.sentimentservice" ]
// *** Define Targets ***
Target.Create "Clean" (fun _ ->
!! "src/*/*/bin" |> Shell.CleanDirs
)
Target.Create "InstallDotnetCore" (fun _ ->
DotnetCliInstall (fun x -> { x with Version = Version(GetDotNetSDKVersionFromGlobalJson()) })
)
Target.Create "DownloadPaket" (fun _ ->
if 0 <> Process.ExecProcess (fun info ->
{ info with
FileName = ".paket/paket.exe"
Arguments = "--version" }
) (System.TimeSpan.FromMinutes 5.0) then
failwith "paket failed to start"
)
Target.Create "Restore" (fun _ ->
DotnetRestore (fun x -> x) solutionFile
)
Target.Create "Build" (fun _ ->
DotnetBuild (fun x -> { x with Configuration = Release }) solutionFile
)
Target.Create "Publish" (fun _ ->
for project in dockerProjects do
DotnetPublish (fun x -> { x with Configuration = Release; OutputPath = Some "./obj/Docker/publish" }) project
)
Target.Create "DockerComposeRemove" (fun _ ->
let result =
Process.ExecProcessAndReturnMessages(fun (info:Process.ProcStartInfo) ->
{info with
FileName = "docker-compose"
Arguments = "rm -f"}) (System.TimeSpan.FromMinutes 15.)
if result.ExitCode <> 0 then failwith "Docker Compose up failed"
)
Target.Create "DockerComposeBuild" (fun _ ->
let result =
Process.ExecProcessAndReturnMessages(fun (info:Process.ProcStartInfo) ->
{info with
FileName = "docker-compose"
Arguments = sprintf "-f %s build" dockerComposeFileName}) (System.TimeSpan.FromMinutes 15.)
if result.ExitCode <> 0 then failwith "Docker Compose up failed"
)
Target.Create "DockerComposeUp" (fun _ ->
let result =
Process.ExecProcessAndReturnMessages(fun (info:Process.ProcStartInfo) ->
{info with
FileName = "docker-compose"
Arguments = sprintf "-f %s up" dockerComposeFileName}) (System.TimeSpan.FromMinutes 15.)
if result.ExitCode <> 0 then failwith "Docker Compose up failed"
)
open Fake.Core.TargetOperators
// *** Define Dependencies ***
"Clean"
==> "InstallDotnetCore"
==> "DownloadPaket"
==> "Restore"
==> "Build"
==> "Publish"
==> "DockerComposeRemove"
==> "DockerComposeBuild"
==> "DockerComposeUp"
// *** Start Build ***
Target.RunOrDefault "DockerComposeUp"