From b00e469e430e8c34789186a5796cb2748ae77d09 Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Fri, 29 Nov 2024 15:30:21 +0000 Subject: [PATCH 1/3] Tezt_cloud: Propagate the macosx argument to env --- tezt/lib_cloud/env.ml | 2 ++ tezt/lib_cloud/env.mli | 3 +++ 2 files changed, 5 insertions(+) diff --git a/tezt/lib_cloud/env.ml b/tezt/lib_cloud/env.ml index 47f38dee220c..8f2e9f5bb324 100644 --- a/tezt/lib_cloud/env.ml +++ b/tezt/lib_cloud/env.ml @@ -79,6 +79,8 @@ let dockerfile = Path.dockerfile ~alias:dockerfile_alias let docker_registry = Format.asprintf "%s-docker-registry" tezt_cloud +let macosx = Cli.macosx + let check_file_consistency = Cli.check_file_consistency let project_id = Gcloud.project_id diff --git a/tezt/lib_cloud/env.mli b/tezt/lib_cloud/env.mli index 4eb5d01fefc2..9ae789f6cff7 100644 --- a/tezt/lib_cloud/env.mli +++ b/tezt/lib_cloud/env.mli @@ -108,6 +108,9 @@ val dockerfile : string (** Docker registry path associated to [tezt_cloud]. *) val docker_registry : string +(** Equivalent to [Cli.macosx]. *) +val macosx : bool + (** Equivalent to [Cli.check_file_consistency]. *) val check_file_consistency : bool -- GitLab From bb103fca27da27e29e20a9df59f509efd825ac96 Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Fri, 29 Nov 2024 15:31:19 +0000 Subject: [PATCH 2/3] Tezt_cloud: Use macosx variable for network argument of docker run --- tezt/lib_cloud/deployement.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tezt/lib_cloud/deployement.ml b/tezt/lib_cloud/deployement.ml index 898a8d912abe..93b09de8a804 100644 --- a/tezt/lib_cloud/deployement.ml +++ b/tezt/lib_cloud/deployement.ml @@ -285,11 +285,15 @@ module Localhost = struct let* docker_image = Env.uri_of_docker_image configuration.docker_image in + (* FIXME: The docker host networking feature is not supported on macOS. + We want to remove it in the future for all distributions, but it + requires more testing. *) + let network = if Env.macosx then None else Some "host" in let process = Docker.run ~rm:true ~name - ~network:"host" + ?network ~publish_ports docker_image ["-D"; "-p"; start; "-e"] -- GitLab From 62cf48d2f88a1fd88ba4c877f1aa1078bec765cc Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Mon, 2 Dec 2024 17:43:49 +0000 Subject: [PATCH 3/3] Tezt_cloud: Add --platform argument for macosx users --- tezt/lib_cloud/docker.ml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tezt/lib_cloud/docker.ml b/tezt/lib_cloud/docker.ml index a2bf45398f0e..8f3da2a92bac 100644 --- a/tezt/lib_cloud/docker.ml +++ b/tezt/lib_cloud/docker.ml @@ -9,6 +9,9 @@ let name = "docker" let color = Log.Color.FG.yellow +let macos_platform_arg = + if Env.macosx then ["--platform"; "linux/amd64"] else [] + let build ?image_name ?alias ?(tag = "latest") ?dockerfile ~args () = let build_args = args @@ -20,7 +23,9 @@ let build ?image_name ?alias ?(tag = "latest") ?dockerfile ~args () = let dockerfile = Option.value ~default:(Path.dockerfile ~alias) dockerfile in let image_name = Option.value ~default:alias image_name in let tag = ["-t"; Format.asprintf "%s:%s" image_name tag] in - let args = ["build"; "-f"; dockerfile] @ build_args @ tag @ ["."] in + let args = + ["build"; "-f"; dockerfile] @ macos_platform_arg @ build_args @ tag @ ["."] + in Process.spawn ~name ~color "docker" args let tag ?image_name ?alias ?(tag = "latest") ~registry_uri () = @@ -64,7 +69,7 @@ let run ?(rm = false) ?name ?network ?publish_ports image args = Process.spawn ~color "docker" - (["run"] @ rm @ name @ network @ publish_ports + (["run"] @ rm @ name @ macos_platform_arg @ network @ publish_ports @ [Format.asprintf "%s" image] @ args) -- GitLab