Skip to content

Commit

Permalink
fix: OR-2009 update build.fsx with updated containerize
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Lesage committed Dec 11, 2023
1 parent acc2ccc commit b4fc78e
Showing 1 changed file with 45 additions and 13 deletions.
58 changes: 45 additions & 13 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ let product = "Basisregisters Vlaanderen"
let copyright = "Copyright (c) Vlaamse overheid"
let company = "Vlaamse overheid"

let dockerRepository = "association-registry"
let assemblyVersionNumber = (sprintf "%s.0")
let nugetVersionNumber = (sprintf "%s")

Expand All @@ -27,8 +26,41 @@ let setVersions = (setSolutionVersions assemblyVersionNumber product copyright c
let test = testSolution
let publishSource = publish assemblyVersionNumber
let pack = pack nugetVersionNumber
let containerize = containerize dockerRepository
let push = push dockerRepository

let containerize project containerName =
let result1 =
[ "build"; "."; "--no-cache"; "--tag"; sprintf "%s/%s:%s" dockerRegistry containerName buildNumber; "--build-arg"; sprintf "build_number=%s" buildNumber]
|> CreateProcess.fromRawCommand "docker"
|> CreateProcess.withWorkingDirectory (buildDir @@ project @@ "linux")
|> 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" dockerRegistry containerName buildNumber; sprintf "%s/%s:latest" dockerRegistry containerName]
|> CreateProcess.fromRawCommand "docker"
|> CreateProcess.withTimeout (TimeSpan.FromMinutes 5.)
|> Proc.run

if result2.ExitCode <> 0 then failwith "Failed result from Docker Tag"

let push containerName =
let result1 =
[ "push"; sprintf "%s/%s:%s" dockerRegistry containerName buildNumber]
|> CreateProcess.fromRawCommand "docker"
|> CreateProcess.withTimeout (TimeSpan.FromMinutes 5.)
|> Proc.run

if result1.ExitCode <> 0 then failwith "Failed result from Docker Push"

let result2 =
[ "push"; sprintf "%s/%s:latest" dockerRegistry containerName]
|> CreateProcess.fromRawCommand "docker"
|> CreateProcess.withTimeout (TimeSpan.FromMinutes 5.)
|> Proc.run

if result2.ExitCode <> 0 then failwith "Failed result from Docker Push Latest"

supportedRuntimeIdentifiers <- [ "msil"; "linux-x64" ]

Expand Down Expand Up @@ -67,20 +99,20 @@ Target.create "Publish_Solution" (fun _ ->
"AssociationRegistry.Admin.ProjectionHost"
] |> List.iter publishSource)

Target.create "Containerize_AcmApi" (fun _ -> containerize "AssociationRegistry.Acm.Api" "acm-api")
Target.create "PushContainer_AcmApi" (fun _ -> push "acm-api")
Target.create "Containerize_AcmApi" (fun _ -> containerize "AssociationRegistry.Acm.Api" "verenigingsregister-acmapi")
Target.create "PushContainer_AcmApi" (fun _ -> push "verenigingsregister-acmapi")

Target.create "Containerize_PublicApi" (fun _ -> containerize "AssociationRegistry.Public.Api" "public-api")
Target.create "PushContainer_PublicApi" (fun _ -> push "public-api")
Target.create "Containerize_PublicApi" (fun _ -> containerize "AssociationRegistry.Public.Api" "verenigingsregister-publicapi")
Target.create "PushContainer_PublicApi" (fun _ -> push "verenigingsregister-publicapi")

Target.create "Containerize_PublicProjections" (fun _ -> containerize "AssociationRegistry.Public.ProjectionHost" "public-projections")
Target.create "PushContainer_PublicProjections" (fun _ -> push "public-projections")
Target.create "Containerize_PublicProjections" (fun _ -> containerize "AssociationRegistry.Public.ProjectionHost" "verenigingsregister-publicprojections")
Target.create "PushContainer_PublicProjections" (fun _ -> push "verenigingsregister-publicprojections")

Target.create "Containerize_AdminApi" (fun _ -> containerize "AssociationRegistry.Admin.Api" "admin-api")
Target.create "PushContainer_AdminApi" (fun _ -> push "admin-api")
Target.create "Containerize_AdminApi" (fun _ -> containerize "AssociationRegistry.Admin.Api" "verenigingsregister-adminapi")
Target.create "PushContainer_AdminApi" (fun _ -> push "verenigingsregister-adminapi")

Target.create "Containerize_AdminProjections" (fun _ -> containerize "AssociationRegistry.Admin.ProjectionHost" "admin-projections")
Target.create "PushContainer_AdminProjections" (fun _ -> push "admin-projections")
Target.create "Containerize_AdminProjections" (fun _ -> containerize "AssociationRegistry.Admin.ProjectionHost" "verenigingsregister-adminprojections")
Target.create "PushContainer_AdminProjections" (fun _ -> push "verenigingsregister-adminprojections")

// --------------------------------------------------------------------------------

Expand Down

0 comments on commit b4fc78e

Please sign in to comment.