Containers
Precept.Containers starts a Docker dependency through Testcontainers and hands tests its address.
A container starts once per run, on first use, not once per test. A configured address overrides
the container entirely, so the same suite runs against a throwaway container locally and against a
deployed environment in CI:
services.AddPreceptContainers(host => host.Register(
"greeter",
"my/greeter:latest",
c => c.WithPortBinding(5000, true)
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(5000)),
addressOverride: settings.Configuration["Greeter:Address"]));
A test asks for the address by name. ContainerHost.AddressAsync("greeter", 5000) returns the
configured address if there is one, and otherwise starts the container and returns its mapped
address. GetAsync("greeter") returns the running Testcontainers IContainer instead.
Every container is stopped when the run's service container is disposed, after AfterRunAsync. The
builder callback receives Testcontainers' own builder, so every option the library has is available.