testcontainers-java icon indicating copy to clipboard operation
testcontainers-java copied to clipboard

[Enhancement]: Add OpenFGAContainer

Open rwinch opened this issue 1 year ago • 0 comments

Module

Core

Proposal

Spring Security is currently working on adding support for OpenFGA and I think that adding official Testcontainers support for OpenFga's Existing Docker Image . I'm able to do this with a GenericContainer, but it is a little bit of work to get working because the default checks do not work due to the image being hardened (e.g. /bin/sh is not available).

For the record this is what I'm currently doing (it could certainly use polish as well):


@Bean
GenericContainer<?> openFgaContainer(DynamicPropertyRegistry registry) {
var result = new GenericContainer<>("openfga/openfga:latest")
		.withCommand("run")
		.waitingFor(Wait.forHttp("/playground").forPort(3000).withStartupTimeout(Duration.ofMinutes(2)))
		.withEnv("OPENFGA_HTTP_ADDR","0.0.0.0:4000")
		.withExposedPorts(4000, 8081, 3000);
registry.add("openfga.fgaApiUrl", () -> {
	Integer httpPort = result.getMappedPort(4000);
	return "http://localhost:"+httpPort;
});
return result;
}

rwinch avatar Feb 22 '24 15:02 rwinch