testing-environment.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. if [ "$RUNTIME" = "" ];
  3. then
  4. export RUNTIME="`which podman`"
  5. if [ "$RUNTIME" = "" ];
  6. then
  7. export RUNTIME="`which docker`"
  8. fi
  9. fi
  10. echo "Use runtime $RUNTIME"
  11. function stop {
  12. echo "Stop!"
  13. $RUNTIME stop jmestore-testing-mysql ||true
  14. $RUNTIME stop jmestore-testing-pma ||true
  15. $RUNTIME stop jmestore-testing-store ||true
  16. $RUNTIME rm jmestore-testing-mysql ||true
  17. $RUNTIME rm jmestore-testing-pma ||true
  18. $RUNTIME rm jmestore-testing-store ||true
  19. $RUNTIME network rm jmestore_testing_net|| true
  20. }
  21. function start {
  22. stop
  23. echo "Start!"
  24. mkdir -p "$PWD/test_environment"
  25. mkdir -p "$PWD/test_environment/mysql"
  26. $RUNTIME network create -d bridge jmestore_testing_net
  27. $RUNTIME run --rm -d \
  28. --name jmestore-testing-mysql \
  29. -v "$PWD/test_environment/mysql":/var/lib/mysql \
  30. -e MYSQL_ROOT_PASSWORD="oEZi1nIeZwpS" \
  31. -p 3306:3306 \
  32. mariadb
  33. $RUNTIME network connect --alias mysql jmestore_testing_net jmestore-testing-mysql
  34. $RUNTIME run -d --rm --name jmestore-testing-pma \
  35. -e PMA_HOST=jmestore-testing-mysql \
  36. -p 8081:80 \
  37. phpmyadmin/phpmyadmin
  38. $RUNTIME network connect --alias phpmyadmin.mysql jmestore_testing_net jmestore-testing-pma
  39. if [ "$RUN_STORE" != "" ];
  40. then
  41. mkdir -p "$PWD/test_environment/store_config"
  42. mkdir -p "$PWD/test_environment/store_images"
  43. rm -f "$PWD/test_environment/store_config/server-config.json" || true
  44. cp "config/test-environment-config.json" "$PWD/test_environment/store_config/server-config.json"
  45. $RUNTIME create --rm --name jmestore-testing-store \
  46. --read-only \
  47. -v"$PWD/test_environment/store_config":/app/config \
  48. -v"$PWD/test_environment/store_images":/app/www/images/database \
  49. --tmpfs /app/sitemap \
  50. --tmpfs /tmp/apptmp \
  51. -p 8080:8080 \
  52. jmestore
  53. $RUNTIME network connect --alias store.docker jmestore_testing_net jmestore-testing-store
  54. $RUNTIME start jmestore-testing-store
  55. $RUNTIME logs --follow jmestore-testing-store
  56. fi
  57. }
  58. $1