Terminate docker compose when test container finishes

前端 未结 6 1139
梦毁少年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:33

    To avoid having separate config files you can update the docker-compose configuration to introduce the dependencies between services with the depends_on option, available from version 2 format and up. As result start of the test-runner will initiate the run of the clients.

    Please note that if you need to wait some time when the actual web server will be started from inside services you are testing, you can use wait-for-it.sh script to wait until the server became available.

    # Test runner
    test-runner:
      image: "${RUNNER_IMG}"
      privileged: true
      links:
        - client
        - server
      volumes:
      - /Users/me/frontend_test/client-devops:/protractor/project
      - /dev/shm:/dev/shm
      depends_on:
        - client
      entrypoint:
        - wait-for-it.sh
        - client
        - -t
        - '180'
        - --
        - /entrypoint.sh
        - --baseUrl=http://client:9000/dist/
        - /protractor/conf-dev.js
        - --suite=remember
    # Client deployment
    client:
      image: "${CLIENT_IMG}"
      depends_on:
        - server
      links:
        - server
    # Server deployment
    server:
      image: "${SERVER_IMG}"
    

    After updating config, simple docker-compose up test-runner will trigger start of the related services.

提交回复
热议问题