Skip to content

Allow reuse of containers needed by DevServices (opt-in)#25367

Merged
Sanne merged 2 commits intoquarkusio:mainfrom
Sanne:ContainersReuse
May 5, 2022
Merged

Allow reuse of containers needed by DevServices (opt-in)#25367
Sanne merged 2 commits intoquarkusio:mainfrom
Sanne:ContainersReuse

Conversation

@Sanne
Copy link
Copy Markdown
Member

@Sanne Sanne commented May 4, 2022

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.

@Sanne Sanne force-pushed the ContainersReuse branch from 5958323 to a589b97 Compare May 4, 2022 13:27
@Sanne Sanne force-pushed the ContainersReuse branch from a589b97 to 02e43fe Compare May 4, 2022 13:27
Copy link
Copy Markdown
Member

@gastaldi gastaldi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@gastaldi
Copy link
Copy Markdown
Member

gastaldi commented May 4, 2022

If you have a file named .testcontainers.properties in your ~ and add: testcontainers.reuse.enable=true

Can we have this documented somewhere before merging this PR?

@Sanne
Copy link
Copy Markdown
Member Author

Sanne commented May 4, 2022

If you have a file named .testcontainers.properties in your ~ and add: testcontainers.reuse.enable=true

Can we have this documented somewhere before merging this PR?

Where would you look for it? It's a bit specific to Testcontainers

@gastaldi
Copy link
Copy Markdown
Member

gastaldi commented May 4, 2022

@Sanne
Copy link
Copy Markdown
Member Author

Sanne commented May 4, 2022

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.

@GregJohnStewart
Copy link
Copy Markdown
Contributor

Would we want to wrap the config for this into the devservices config, rather than need an additional file to config with?

@stuartwdouglas
Copy link
Copy Markdown
Collaborator

+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.

Copy link
Copy Markdown
Contributor

@geoand geoand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@Sanne
Copy link
Copy Markdown
Member Author

Sanne commented May 5, 2022

Would we want to wrap the config for this into the devservices config, rather than need an additional file to config with?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow reuse of containers started via DevServices

5 participants