From ef6360115ff323ea0e54d58c6b7ceb41dfca7c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarl=20Andr=C3=A9=20H=C3=BCbenthal?= Date: Thu, 12 Oct 2023 13:47:02 +0200 Subject: [PATCH] add a start for a reaper genserver --- lib/reaper.ex | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/reaper.ex diff --git a/lib/reaper.ex b/lib/reaper.ex new file mode 100644 index 0000000..0cd216a --- /dev/null +++ b/lib/reaper.ex @@ -0,0 +1,25 @@ +defmodule TestcontainersElixir.Reaper do + use GenServer + + @impl true + @spec init(Tesla.Env.client()) :: {:ok, DockerEngineAPI.Model.ContainerCreateResponse.t()} + def init(connection) do + request = %DockerEngineAPI.Model.ContainerCreateRequest{ + Image: "testcontainers/ryuk:0.5.1", + ExposedPorts: %{"8080" => %{}}, + HostConfig: %{ + PortBindings: %{"8080" => [%{"HostPort" => "8080"}]}, + Privileged: true, + Binds: ["/var/run/docker.sock:/var/run/docker.sock:rw"] + }, + Env: ["RYUK_PORT=8080"] + } + + {:ok, container} = connection |> DockerEngineAPI.Api.Container.container_create(request) + {:ok, container} = connection |> DockerEngineAPI.Api.Container.container_start(container."Id") + # TODO establish socket connection + # TODO send first message + # TODO return {:ok, {container, socket}} for ex + {:ok, container} + end +end