@@ -16,6 +16,12 @@ let aliases_of =
1616
1717let master_distro = Distro. ((resolve_alias master_distro : distro :> t ))
1818
19+ (* Windows Containers don't support BuildKit as of v0.12.2.
20+ https://github.com/microsoft/Windows-Containers/issues/34 *)
21+ let buildkit : Distro.os_family -> bool = function
22+ | `Windows | `Cygwin -> false
23+ | `Linux -> true
24+
1925type 'a run = ('a , unit , string , Dockerfile .t ) format4 -> 'a
2026
2127let maybe_add_beta (run : 'a run ) switch =
@@ -96,13 +102,13 @@ let install_compiler_df ~distro ~arch ~switch ?windows_port opam_image =
96102 maybe_install_secondary_compiler run os_family switch @@
97103 entrypoint_exec (Option. to_list personality @ opam_exec) @@
98104 (match os_family with
99- | `Linux ->
105+ | `Linux | `Cygwin ->
106+ let link = buildkit os_family in
100107 cmd " bash" @@
101- copy ~link: true ~src: [" Dockerfile" ] ~dst: " /Dockerfile.ocaml" ()
108+ copy ~link ~src: [" Dockerfile" ] ~dst: " /Dockerfile.ocaml" ()
102109 | `Windows ->
103110 cmd_exec [" cmd.exe" ] @@
104- copy ~src: [" Dockerfile" ] ~dst: " /Dockerfile.ocaml" ()
105- | `Cygwin -> failwith " No support for Cygwin currently." )
111+ copy ~src: [" Dockerfile" ] ~dst: " /Dockerfile.ocaml" () )
106112
107113let or_die = function
108114 | Ok x -> x
@@ -120,14 +126,10 @@ module Make (OCurrent : S.OCURRENT) = struct
120126
121127 (* Pipeline to build the opam base image and the compiler images for a particular architecture. *)
122128 module Arch = struct
123- (* 2020-04-29: On Windows, squashing images is still experimental (broken). *)
124- let squash distro =
125- Distro. os_family_of_distro distro <> `Windows
126-
127- (* 2022-07-18: Windows Containers don't support BuildKit.
128- https://github.com/microsoft/Windows-Containers/issues/34 *)
129- let buildkit distro =
130- Distro. os_family_of_distro distro <> `Windows
129+ (* On Windows, squashing images is still experimental (broken). *)
130+ let squash : Distro.os_family -> bool = function
131+ | `Windows | `Cygwin -> false
132+ | `Linux -> true
131133
132134 let install_opam ~arch ~ocluster ~distro ~repos ~push_target =
133135 let arch_name = Ocaml_version. string_of_arch arch in
@@ -146,12 +148,13 @@ module Make (OCurrent : S.OCURRENT) = struct
146148 string_of_t (
147149 opam @@
148150 begin match os_family with
149- | `Linux ->
150- copy ~link: true ~chown: " opam:opam" ~src: [" ." ] ~dst: " /home/opam/opam-repository" () @@
151+ | `Linux | `Cygwin ->
152+ let link = buildkit os_family in
153+ copy ~link ~chown: " opam:opam" ~src: [" ." ] ~dst: " /home/opam/opam-repository" () @@
151154 run " opam-sandbox-disable" @@
152155 run " opam init -k local -a /home/opam/opam-repository --bare" @@
153156 run " rm -rf .opam/repo/default/.git" @@
154- copy ~link: true ~src: [" Dockerfile" ] ~dst: " /Dockerfile.opam" ()
157+ copy ~link ~src: [" Dockerfile" ] ~dst: " /Dockerfile.opam" ()
155158 | `Windows ->
156159 let opam_repo = Windows.Cygwin. default.root ^ {| \home\opam\opam- repository| } in
157160 let opam_root = {| C :\opam\.opam| } in
@@ -161,13 +164,12 @@ module Make (OCurrent : S.OCURRENT) = struct
161164 maybe_add_overlay distro (Current_git.Commit_id. hash opam_overlays) @@
162165 Windows.Cygwin. run_sh " rm -rf /cygdrive/c/opam/.opam/repo/default/.git" @@
163166 copy ~src: [" Dockerfile" ] ~dst: " /Dockerfile.opam" ()
164- | `Cygwin -> failwith " No support for Cygwin currently."
165167 end )
166168 )
167169 in
168170 let options = { Cluster_api.Docker.Spec. defaults with
169- squash = squash distro ;
170- buildkit = buildkit distro ;
171+ squash = squash os_family ;
172+ buildkit = buildkit os_family ;
171173 include_git = true } in
172174 let cache_hint = Printf. sprintf " opam-%s" distro_tag in
173175 let opam_repository = match os_family with `Windows -> opam_repository_mingw_sunset | _ -> opam_repository_master in
@@ -183,10 +185,12 @@ module Make (OCurrent : S.OCURRENT) = struct
183185 let > base = base in
184186 let dockerfile = `Contents (install_compiler_df ~distro ~arch ~switch ?windows_port base |> Dockerfile. string_of_t) in
185187 (* ([include_git] doesn't do anything here, but it saves rebuilding during the upgrade) *)
186- let options = { Cluster_api.Docker.Spec. defaults with
187- squash = squash distro;
188- buildkit = buildkit distro;
189- include_git = true } in
188+ let options =
189+ let os_family = Dockerfile_opam.Distro. os_family_of_distro distro in
190+ { Cluster_api.Docker.Spec. defaults with
191+ squash = squash os_family;
192+ buildkit = buildkit os_family;
193+ include_git = true } in
190194 let cache_hint = Printf. sprintf " %s-%s-%s" (Ocaml_version. to_string switch) arch_name base in
191195 OCluster.Raw. build_and_push ocluster ~src: [] dockerfile
192196 ~cache_hint
@@ -198,10 +202,12 @@ module Make (OCurrent : S.OCURRENT) = struct
198202 Current. component " archive" |>
199203 let > base = base in
200204 let dockerfile = `Contents (install_package_archive base |> Dockerfile. string_of_t) in
201- let options = { Cluster_api.Docker.Spec. defaults with
202- squash = squash distro;
203- buildkit = buildkit distro;
204- include_git = true } in
205+ let options =
206+ let os_family = Dockerfile_opam.Distro. os_family_of_distro distro in
207+ { Cluster_api.Docker.Spec. defaults with
208+ squash = squash os_family;
209+ buildkit = buildkit os_family;
210+ include_git = true } in
205211 let cache_hint = Printf. sprintf " archive-%s" base in
206212 OCluster.Raw. build_and_push ocluster ~src: [] dockerfile
207213 ~cache_hint
0 commit comments