From ef51a3aaa85d994499f14f2cd92d420cb6f9b70f Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Thu, 9 Jan 2025 13:20:26 +0200 Subject: [PATCH 1/4] Tezt_cloud: Add custom docker network for macos --- tezt/lib_cloud/deployement.ml | 24 ++++++++++++++++++++---- tezt/lib_cloud/docker.ml | 3 +++ tezt/lib_cloud/docker.mli | 3 +++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/tezt/lib_cloud/deployement.ml b/tezt/lib_cloud/deployement.ml index 0dff8d04a89c..292bb30fb996 100644 --- a/tezt/lib_cloud/deployement.ml +++ b/tezt/lib_cloud/deployement.ml @@ -267,10 +267,21 @@ module Localhost = struct let vm_name i = Format.asprintf "%s-%03d" Env.tezt_cloud (i + 1) + let macosx_docker_network = Env.tezt_cloud ^ "-net" + let deploy ~configurations () = let number_of_vms = List.length configurations in let base_port = Env.vm_base_port in let ports_per_vm = Env.ports_per_vm in + let network, start_macosx_docker_network = + if Env.macosx then + ( Some macosx_docker_network, + Some + (Docker.network + ~command:"create" + ~network_name:macosx_docker_network) ) + else (None, None) + in let* processes = List.to_seq configurations |> Seq.mapi (fun i configuration -> @@ -289,13 +300,11 @@ 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 process = Docker.run ~rm:true ~name + ?network ~publish_ports docker_image ["-D"; "-p"; start; "-e"] @@ -358,7 +367,14 @@ module Localhost = struct ~name ()) in - Lwt.return {number_of_vms; processes; base_port; ports_per_vm; agents} + Lwt.return + { + number_of_vms; + processes = Option.to_list start_macosx_docker_network @ processes; + base_port; + ports_per_vm; + agents; + } let agents t = t.agents diff --git a/tezt/lib_cloud/docker.ml b/tezt/lib_cloud/docker.ml index 8f3da2a92bac..f30fa419fc74 100644 --- a/tezt/lib_cloud/docker.ml +++ b/tezt/lib_cloud/docker.ml @@ -52,6 +52,9 @@ let pull ?image_name ?alias ?(tag = "latest") ~registry_uri () = let args = ["pull"; Format.asprintf "%s/%s:%s" registry_uri image_name tag] in Process.spawn ~name ~color "docker" args +let network ~command ~network_name = + Process.spawn ~color "docker" (["network"] @ [command] @ [network_name]) + let run ?(rm = false) ?name ?network ?publish_ports image args = let publish_ports = match publish_ports with diff --git a/tezt/lib_cloud/docker.mli b/tezt/lib_cloud/docker.mli index 693817cdf196..0b5cc4970f72 100644 --- a/tezt/lib_cloud/docker.mli +++ b/tezt/lib_cloud/docker.mli @@ -44,6 +44,9 @@ val pull : unit -> Process.t +(** [network ~command ~network_name] is an alias for [docker network command network_name]. *) +val network : command:string -> network_name:string -> Process.t + (** [run] is an alias for [docker run]. *) val run : ?rm:bool -> -- GitLab From 54c7c14e348ad1e67672799204fd689b41418d18 Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Tue, 7 Jan 2025 17:23:24 +0200 Subject: [PATCH 2/4] Tezt_cloud: Add macosx dockerfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François Thiré This work has been done by François Thiré. Thanks a lot for that! --- tezt/lib_cloud/dockerfiles/macosx.Dockerfile | 46 +++++++++++++++++++ .../macosx.Dockerfile.dockerignore | 0 2 files changed, 46 insertions(+) create mode 100644 tezt/lib_cloud/dockerfiles/macosx.Dockerfile create mode 100644 tezt/lib_cloud/dockerfiles/macosx.Dockerfile.dockerignore diff --git a/tezt/lib_cloud/dockerfiles/macosx.Dockerfile b/tezt/lib_cloud/dockerfiles/macosx.Dockerfile new file mode 100644 index 000000000000..97f748c39920 --- /dev/null +++ b/tezt/lib_cloud/dockerfiles/macosx.Dockerfile @@ -0,0 +1,46 @@ +# This image needs to be updated from time to time, as the code evolves. +# FIXME: Can we automatically get one, instead of hardcoding? +FROM us-central1-docker.pkg.dev/nl-gitlab-runner/registry/tezos/tezos/ci/build@sha256:c826a00735d97e66b56e00ebe52f7d32c19b059acc5a073f3a4e96057a63342c AS step1 + +FROM step1 AS step2 +WORKDIR /build +RUN git init tezos +WORKDIR /build/tezos +RUN git remote add origin https://gitlab.com/tezos/tezos.git +# This commit was hardcoded. It is supposed to be a recent commit, if the user +# encounters errors, because of incompatibilities between current master and +# given commit, please change the commit locally to something more recent. +# FIXME: Can we get the latest commit instead? +RUN git fetch --depth 1 origin 093ed36b2ee3b5882434d18008c8e41f8a12bf25 +RUN git checkout 093ed36b2ee3b5882434d18008c8e41f8a12bf25 +RUN ./scripts/slim-mode.sh on +RUN eval $(opam env) && make octez-node + +# This step might not be necessary for some environments, depending on docker. +# Overall, it should speed things up for local changes to octez. +FROM step2 + +ARG COMMIT +RUN git fetch --depth 1 origin $COMMIT +RUN git checkout $COMMIT +RUN eval $(opam env) && make octez-node octez-dal-node octez-client octez-baker-alpha + + +USER root +# SSH key that will be used for the SSH server +ARG SSH_PUBLIC_KEY + +# This is extracted from the link below +# https://dev.to/yakovlev_alexey/running-ssh-in-an-alpine-docker-container-3lop +RUN mkdir -p /root/.ssh \ + && chmod 0700 /root/.ssh \ + && echo "$SSH_PUBLIC_KEY" > /root/.ssh/authorized_keys \ + && apk add openrc openssh \ + && ssh-keygen -A \ + && echo -e "PasswordAuthentication no" >> /etc/ssh/sshd_config \ + && mkdir -p /run/openrc \ + && touch /run/openrc/softlevel + +CMD ["-D", "-p", "30000", "-e"] +ENTRYPOINT ["/usr/sbin/sshd"] + diff --git a/tezt/lib_cloud/dockerfiles/macosx.Dockerfile.dockerignore b/tezt/lib_cloud/dockerfiles/macosx.Dockerfile.dockerignore new file mode 100644 index 000000000000..e69de29bb2d1 -- GitLab From e71c90166cee33dd5d9a2ecc46de44a0fcbcaf6d Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Tue, 7 Jan 2025 18:13:58 +0200 Subject: [PATCH 3/4] Tezt_cloud: Fix the path of octez-dal-node agent --- tezt/tests/cloud/tezos.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tezt/tests/cloud/tezos.ml b/tezt/tests/cloud/tezos.ml index bb1a705c7744..0c2edf3ab4c2 100644 --- a/tezt/tests/cloud/tezos.ml +++ b/tezt/tests/cloud/tezos.ml @@ -80,8 +80,8 @@ module Dal_node = struct module Agent = struct let create_from_endpoint ?net_port - ?(path = Uses.path Constant.octez_dal_node |> Filename.basename) ?name - ?rpc_port ~l1_node_endpoint agent = + ?(path = Uses.path Constant.octez_dal_node) ?name ?rpc_port + ~l1_node_endpoint agent = let* path = Agent.copy agent ~source:path in let runner = Agent.runner agent in let rpc_port = -- GitLab From 0a4faf279a380f564a4db69a0be58a1b5b337cb1 Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Fri, 10 Jan 2025 12:42:47 +0000 Subject: [PATCH 4/4] Tezt_cloud: Add README information about the new dockerfile --- tezt/lib_cloud/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tezt/lib_cloud/README.md b/tezt/lib_cloud/README.md index 572409f15873..7f796b0122df 100644 --- a/tezt/lib_cloud/README.md +++ b/tezt/lib_cloud/README.md @@ -101,6 +101,11 @@ possible to use docker images published by the Octez CI. At the moment, the docker image from the latest release of Octez is supported. +There is now also a docker file that can be used for macOS distributions, +which is provided in `tezt/lib_cloud/dockerfiles/macosx.Dockerfile`. Please +note that this image is highly experimental, and several improvements are +to be made to it, but it should work for the time being. + ## Write your own dockerfile Depending on your local setup, we recommend copying and pasting an -- GitLab