Terminate docker compose when test container finishes

前端 未结 6 1152
梦毁少年i
梦毁少年i 2021-01-30 16:56

I am currently running a docker-compose stack for basic integration tests with a protractor test runner, a nodejs server serving a web page and a wildfly server serving a java b

6条回答
  •  春和景丽
    2021-01-30 17:25

    The solution I found to be most elegant is to use depends_on in your docker-compose.yml file.

    services:
      dynamodb:
      ...
      test_runner:
        ...
        depends_on:
          - dynamodb
    

    Now you can use docker-compose run --rm test_runner which will set up your dependencies, run your tests, tear down everything, and propagate the return code.

    docker-compose run test_runner false
    Starting test_dynamodb_1 ... done
    echo $?
    1
    docker-compose run test_runner true
    Starting test_dynamodb_1 ... done
    echo $?
    

提交回复
热议问题