Skip to content

Commit

Permalink
add a start for a reaper genserver
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlah committed Oct 12, 2023
1 parent 2e20466 commit ef63601
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/reaper.ex
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ef63601

Please sign in to comment.