Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Control docker-compose from Gradle build script

For my tests I need to run containers with e.g. some databases. I have set everything using docker-compose, and if containers are up my tests are working. One note: these are not the unit tests, but integration tests, and they are allowed to run longer.

What would be the best way to control docker-compose from Gradle? I need to run the containers (if not up) and fire the tests. This also should work for OSX and Linux.

like image 544
igr Avatar asked Aug 13 '26 07:08

igr


1 Answers

I think you can run docker-compose up -d using the exec task to start the environment.

And you can run docker-compose stop; docker-compose rm -f as a cleanup task when the tests are done (if you want to stop everything and remove containers).

like image 92
dnephin Avatar answered Aug 14 '26 22:08

dnephin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!