testcontainers / testcontainers-dotnet

A library to support tests with throwaway instances of Docker containers for all compatible .NET Standard versions.
https://dotnet.testcontainers.org
MIT License
3.67k stars 254 forks source link

feat: Add docker compose support (#122) #1082

Open nkz-soft opened 6 months ago

nkz-soft commented 6 months ago

What does this PR do?

Adds docker compose support

Why is it important?

We have docker compose support for java implementations, but that's not here yet. This PR does not contain a complete implementation of all methods in the java library, but it is a starting point from which you can begin to port the rest of the methods.

Related issues

Additional information

At this time, there are only two methods in the DockerComposeBuilder class:

Additional methods are available for implementing in Java, listed in order of importance (to me):

It's my opinion that we should start with the first four methods that cover 90% of the functionality. The implementation of proxy and port forwarding functions in docker-compose can be done directly through a yaml file.

netlify[bot] commented 6 months ago

Deploy Preview for testcontainers-dotnet ready!

Name Link
Latest commit f1417d41de7f0077fbe72e15f7a59c4e3b29d5ca
Latest deploy log https://app.netlify.com/sites/testcontainers-dotnet/deploys/66221036e421140008db4057
Deploy Preview https://deploy-preview-1082--testcontainers-dotnet.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

HofmeisterAn commented 6 months ago

Thanks for the initial PR. Could you please provide additional information in the PR description, specifying which parts are addressed by the PR and which parts are not covered, in comparison to the features provided by Java? Additionally, what aspects do we need to take care of afterward? What follow-ups are necessary, etc.?

nkz-soft commented 6 months ago

Thanks for the initial PR. Could you please provide additional information in the PR description, specifying which parts are addressed by the PR and which parts are not covered, in comparison to the features provided by Java? Additionally, what aspects do we need to take care of afterward? What follow-ups are necessary, etc.?

I have added some additional information, but I am not sure that this is enough. Please take a look at this.

HofmeisterAn commented 6 months ago

I have added some additional information, but I am not sure that this is enough. Please take a look at this.

Thanks. I will need some days to review it. A lot of other topics have accumulated over the holidays.

dmytro-dovhan-gl commented 5 months ago

Hi, Any updates here?

HofmeisterAn commented 5 months ago

Hi, Any updates here?

Sorry, I haven't had the time yet, but it is the next item in my GH inbox. I cannot promise it, but I will try to look at it sometime next week.

nkz-soft commented 5 months ago

Thank you for the PR. Sorry for the late response, I hadn't found the time earlier. I still need to run and test it locally. Meanwhile, I have a couple of suggestions and improvements. It would be great if we could discuss and address them in the meantime. Thanks again for your contribution.

Thanks, I think next week, I'll check and fix all the issues.

nkz-soft commented 5 months ago

Thank you for the PR. Sorry for the late response, I hadn't found the time earlier. I still need to run and test it locally. Meanwhile, I have a couple of suggestions and improvements. It would be great if we could discuss and address them in the meantime. Thanks again for your contribution.

I think it's done, could you please review the code again?

HofmeisterAn commented 3 months ago

Please see my suggestions and comments here: https://github.com/nkz-soft/testcontainers-dotnet/pull/1. Overall, it looks good, but there are still a few things we need to discuss and sort out first.

dava2788 commented 2 months ago

Hello all. Any updates of this PR. Really interesting in using this docker compose functionality

Best Regards

kanpov commented 1 month ago

It'd also be nice to land support for podman's k8s yaml files (podman kube play) as well once podman support is actually finished.

InspiringCode commented 3 weeks ago

@nkz-soft Any updates on this? This would be really useful for our projects too!

nkz-soft commented 5 days ago

@nkz-soft Any updates on this? This would be really useful for our projects too!

@HofmeisterAn Unfortunately, I don't have a clue. I'm still waiting for a code review.

JBastiaan commented 5 days ago

Id also really like to see progress on this, would make setting up testcontainers so much easier in certain scenarios where you already have a docker-compose. So upvote from me :)

HofmeisterAn commented 4 days ago

We need to merge the develop branch and address the build issues first. Additionally, I still believe this does not contain the necessary features developers expect for an MVP. We can split the Docker Compose support into multiple PRs, but we would need something like a feature flag for the current state (opt-in) incl. docs about the current capabilities. The implementation does not or cannot indicate the readiness of the containers (i.e., when the services are actually running, known as wait strategies), nor is it able to retrieve the Docker mapped ports for exposed ports. Which IMO are very basic and necessary features to write reliable tests.