nginx-proxy-tester.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. ###############################################################################
  3. # #
  4. # This script is meant to run the test suite from a Docker container. #
  5. # #
  6. # This is usefull when you want to run the test suite from Mac or #
  7. # Docker Toolbox. #
  8. # #
  9. ###############################################################################
  10. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  11. ARGS="$@"
  12. # check requirements
  13. if [[ "$(docker images -q nginx-proxy-tester 2>/dev/null)" == "" ]]; then
  14. echo "> Building nginx-proxy-tester image..."
  15. docker build -t nginx-proxy-tester -f $DIR/requirements/Dockerfile-nginx-proxy-tester $DIR/requirements
  16. fi
  17. # delete python cache
  18. [[ -d "${DIR}/__pycache__" ]] && rm "${DIR}/__pycache__" -rf
  19. # run the nginx-proxy-tester container setting the correct value for the working dir in order for
  20. # docker-compose to work properly when run from within that container.
  21. docker run --rm -it \
  22. -v ${DIR}:/${DIR} \
  23. -v ${DIR}/__pycache__/ \
  24. -w ${DIR} \
  25. -v /var/run/docker.sock:/var/run/docker.sock \
  26. nginx-proxy-tester "${ARGS}"
  27. PYTEST_EXIT_CODE=$?
  28. # delete python cache
  29. [[ -d "${DIR}/__pycache__" ]] && rm "${DIR}/__pycache__" -rf
  30. exit ${PYTEST_EXIT_CODE}