@@ -16,6 +16,12 @@ let aliases_of =
16
16
17
17
let master_distro = Distro. ((resolve_alias master_distro : distro :> t ))
18
18
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
+
19
25
type 'a run = ('a , unit , string , Dockerfile .t ) format4 -> 'a
20
26
21
27
let maybe_add_beta (run : 'a run ) switch =
@@ -96,13 +102,13 @@ let install_compiler_df ~distro ~arch ~switch ?windows_port opam_image =
96
102
maybe_install_secondary_compiler run os_family switch @@
97
103
entrypoint_exec (Option. to_list personality @ opam_exec) @@
98
104
(match os_family with
99
- | `Linux ->
105
+ | `Linux | `Cygwin ->
106
+ let link = buildkit os_family in
100
107
cmd " bash" @@
101
- copy ~link: true ~src: [" Dockerfile" ] ~dst: " /Dockerfile.ocaml" ()
108
+ copy ~link ~src: [" Dockerfile" ] ~dst: " /Dockerfile.ocaml" ()
102
109
| `Windows ->
103
110
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" () )
106
112
107
113
let or_die = function
108
114
| Ok x -> x
@@ -120,14 +126,10 @@ module Make (OCurrent : S.OCURRENT) = struct
120
126
121
127
(* Pipeline to build the opam base image and the compiler images for a particular architecture. *)
122
128
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
131
133
132
134
let install_opam ~arch ~ocluster ~distro ~repos ~push_target =
133
135
let arch_name = Ocaml_version. string_of_arch arch in
@@ -146,12 +148,13 @@ module Make (OCurrent : S.OCURRENT) = struct
146
148
string_of_t (
147
149
opam @@
148
150
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" () @@
151
154
run " opam-sandbox-disable" @@
152
155
run " opam init -k local -a /home/opam/opam-repository --bare" @@
153
156
run " rm -rf .opam/repo/default/.git" @@
154
- copy ~link: true ~src: [" Dockerfile" ] ~dst: " /Dockerfile.opam" ()
157
+ copy ~link ~src: [" Dockerfile" ] ~dst: " /Dockerfile.opam" ()
155
158
| `Windows ->
156
159
let opam_repo = Windows.Cygwin. default.root ^ {| \home\opam\opam- repository| } in
157
160
let opam_root = {| C :\opam\.opam| } in
@@ -161,13 +164,12 @@ module Make (OCurrent : S.OCURRENT) = struct
161
164
maybe_add_overlay distro (Current_git.Commit_id. hash opam_overlays) @@
162
165
Windows.Cygwin. run_sh " rm -rf /cygdrive/c/opam/.opam/repo/default/.git" @@
163
166
copy ~src: [" Dockerfile" ] ~dst: " /Dockerfile.opam" ()
164
- | `Cygwin -> failwith " No support for Cygwin currently."
165
167
end )
166
168
)
167
169
in
168
170
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 ;
171
173
include_git = true } in
172
174
let cache_hint = Printf. sprintf " opam-%s" distro_tag in
173
175
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
183
185
let > base = base in
184
186
let dockerfile = `Contents (install_compiler_df ~distro ~arch ~switch ?windows_port base |> Dockerfile. string_of_t) in
185
187
(* ([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
190
194
let cache_hint = Printf. sprintf " %s-%s-%s" (Ocaml_version. to_string switch) arch_name base in
191
195
OCluster.Raw. build_and_push ocluster ~src: [] dockerfile
192
196
~cache_hint
@@ -198,10 +202,12 @@ module Make (OCurrent : S.OCURRENT) = struct
198
202
Current. component " archive" |>
199
203
let > base = base in
200
204
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
205
211
let cache_hint = Printf. sprintf " archive-%s" base in
206
212
OCluster.Raw. build_and_push ocluster ~src: [] dockerfile
207
213
~cache_hint
0 commit comments