-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow reuse of containers needed by DevServices (opt-in) #25367
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
Can we have this documented somewhere before merging this PR? |
Where would you look for it? It's a bit specific to Testcontainers |
Perhaps in https://github.com/quarkusio/quarkus/blob/main/docs/src/main/asciidoc/dev-services.adoc as a separate section? |
thanks for the hint @gastaldi , added a couple paragraphs. At this time it's limited to containers used for relational databases so I've only mentioned it in that section; we can expand on this later if people find it useful. |
Would we want to wrap the config for this into the devservices config, rather than need an additional file to config with? |
+1 from me. I had looked at re-use before but I thought it was just for re-using containers inside the same JVM, I did not realize the container could survive JVM exit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
I have wondered the same, but Testcontainers doesn't expose this. We would need to either hot-patch it or to overwrite the user's configuration file - not nice. And it's a rather advanced option of Testcontainers, I think for now I'd rather have the users aware that it's Testcontainers stuff and that they refer their documentation + configuration; it might have other implications and there's more tuning options that I haven't mentioned here. |
Fixes #25365
To try it out, use any demo which is needing a container which is relatively slow to start; for example Oracle database, which will take ~ 1 minute to start.
Run it twice (not in dev-mode), the second time it will need to start the container again.
If you have a file named
.testcontainers.properties
in your ~ and add:testcontainers.reuse.enable=true
you'll notice the container stays alive for some longer time, and the second run is allowed to reuse the same container instance.
I'm sure this workflow isn't for everyone, but since one has to explicitly opt-in I think it's very nice.