Skip to content

Commit

Permalink
make test pass with reaper
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlah committed Oct 12, 2023
1 parent 06d0080 commit bb84d89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/reaper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@
defmodule TestcontainersElixir.Reaper do
use GenServer

@ryuk_image "testcontainers/ryuk:0.5.1"
@ryuk_port 8080

def start_link(connection) do
GenServer.start_link(__MODULE__, connection)
end

def init(connection) do
{:ok, _} =
connection
|> DockerEngineAPI.Api.Image.image_create(fromImage: @ryuk_image)

{:ok, container} =
connection
|> DockerEngineAPI.Api.Container.container_create(
%DockerEngineAPI.Model.ContainerCreateRequest{
Image: "testcontainers/ryuk:0.5.1",
ExposedPorts: %{"8080" => %{}},
Image: @ryuk_image,
ExposedPorts: %{"#{@ryuk_port}" => %{}},
HostConfig: %{
PortBindings: %{"8080" => [%{"HostPort" => ""}]},
Privileged: true,
Expand All @@ -23,7 +30,8 @@ defmodule TestcontainersElixir.Reaper do
)

{:ok, container} =
connection |> DockerEngineAPI.Api.Container.container_start(container."Id")
connection
|> DockerEngineAPI.Api.Container.container_start(container."Id")

# TODO establish socket connection
# TODO send first message
Expand Down
1 change: 1 addition & 0 deletions lib/testcontainers_elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule TestcontainersElixir do
def hello do
connection =
DockerEngineAPI.Connection.new(base_url: "http+unix://%2Fvar%2Frun%2Fdocker.sock/v1.43")

{:ok, _pid} = connection |> TestcontainersElixir.Reaper.start_link()
connection |> DockerEngineAPI.Api.Image.image_list()
end
Expand Down

0 comments on commit bb84d89

Please sign in to comment.