br4chu / docker-compose-maven-plugin

Maven plugin that talks to docker-compose command-line interface
Apache License 2.0
12 stars 4 forks source link

Add 'stop' as an option #3

Closed e220470 closed 4 years ago

e220470 commented 5 years ago

Please add 'stop' as an option as it allows you to end a single container without affecting other dependencies

mjagus commented 4 years ago

Can you provide some more insight? What's the benefit of stopping a single container and leaving others up after the tests are done? Do you run integration tests on a single shared machine? Do you want to save time on subsequent test runs by not resetting containers that don't need to be reset between test runs?

e220470 commented 4 years ago

The way i use the plugin now may not be what it was initially intended for. We have a multi module java maven project. The modules depend on each other for testing and when certain maven profiles are run they will (in sequence) build docker images and a module will use the plugin to start an oracle docker image. then a database module runs a flyway migration and the next module is tested/docker image is built. The oracle image takes about 4 minutes to start and the independent database/migration module cleans and migrates the database anyway. This means being able to stop only the rest-api image for example that uses the database but depends on the data provided during the migration, will allow us to run mvn clean install -Pdocker and the full stack of modules is built, tested and build again, packaged into docker images and then docker images are started. all with one command. This is not for testing but rather for starting a fullstack local dev environment or fullstack tests in Jenkins

mjagus commented 4 years ago

"start" and "stop" goals have been added to the 0.7.0 version of the plugin which is now available on Maven Central. You can provide list of services to stop/start via "startServices" and "stopServices" configuration properties. I also added a basic configuration example to this project's README. Hopefully this should support your use case. If not, feel free to reopen this issue or create a new one.