jimmyjames / fga-spring-examples

simple example demonstrating using FGA in a spring boot application
15 stars 4 forks source link

Use Spring Testcontainers Support #2

Closed rwinch closed 8 months ago

rwinch commented 8 months ago

It might be nice if the samples leveraged Testcontainers support to start up the openfga Docker container instead of requiring it to manually be started.

If this sounds good, I can send a PR for this.

jimmyjames commented 8 months ago

@rwinch that would be a great improvement! Happy to accept a PR 👍

Crain-32 commented 8 months ago

@rwinch Do you think it might be better to use the Spring Docker Compose Approach I've setup in my baseline? I've commented it in the original issue, but I'm interested in that approach just to see if we want to investigate a Docker Compose integration closer to the Service Connections we have with built-in autoconfiguration as I've found those to be amazing for local development.

rwinch commented 8 months ago

Do you think it might be better to use the Spring Docker Compose Approach

@Crain-32 Thanks for the idea! Docker Compose is another approach that works nicely. The advantage to using Testcontainers is that you can map the port of the docker image to a dynamic port (random available port) and update the Spring Environment to use the dynamic port. This ensures that the application will startup without any port collisions if the host machine is already using port 4000 for example.

@jimmyjames I've submitted a PR https://github.com/jimmyjames/fga-spring-examples/pull/4 Apologies for lumping more than one commit in a single PR, but this ensures that you don't have to merge a bunch of PRs in a specific order.