From b4fc78e1c62773891a438827833f31af4c2a09e0 Mon Sep 17 00:00:00 2001 From: Jan Lesage Date: Mon, 11 Dec 2023 11:21:22 +0100 Subject: [PATCH] fix: OR-2009 update build.fsx with updated containerize --- build.fsx | 58 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/build.fsx b/build.fsx index 179bfcabc..7cfcf315f 100755 --- a/build.fsx +++ b/build.fsx @@ -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") @@ -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" ] @@ -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") // --------------------------------------------------------------------------------