1
0

docker_test.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. export DB_USER=root
  3. export DB_PASSWORD=test123456
  4. export DB_HOST=127.0.0.1
  5. export DB_PORT=13306
  6. export REDIS_HOST=127.0.0.1
  7. export REDIS_PORT=16379
  8. export API_PORT=18080
  9. export API_HOST=127.0.0.1
  10. docker rm -f falcon-mysql falcon-redis falcon-plus &> /dev/null
  11. if [[ `uname -m` == "aarch64" ]]; then
  12. docker run --name falcon-mysql -e MYSQL_ROOT_PASSWORD=$DB_PASSWORD -p $DB_PORT:3306 -d mariadb:10.3
  13. else
  14. docker run --name falcon-mysql -e MYSQL_ROOT_PASSWORD=$DB_PASSWORD -p $DB_PORT:3306 -d mysql:5.7
  15. fi
  16. docker run --name falcon-redis -p $REDIS_PORT:6379 -d redis:4-alpine3.8
  17. echo "waiting mysql start..."
  18. sleep 15
  19. for x in `ls ./scripts/mysql/db_schema/*.sql`; do
  20. echo "- - -" $x ...
  21. mysql -h $DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PASSWORD < $x
  22. done
  23. commit_id=`git rev-parse --short HEAD`
  24. image_tag="falcon-plus:$commit_id"
  25. #build docker image from source code
  26. if [[ `uname -m` == "aarch64" ]]; then
  27. docker build -t $image_tag -f Dockerfile_arm64 .
  28. else
  29. docker build -t $image_tag .
  30. fi
  31. ## run falcon-plus container
  32. docker run -itd --name falcon-plus \
  33. --link=falcon-mysql:db.falcon \
  34. --link=falcon-redis:redis.falcon \
  35. -p 18433:8433 \
  36. -p 18080:8080 \
  37. -e MYSQL_PORT=$DB_USER:$DB_PASSWORD@tcp\(db.falcon:3306\) \
  38. -e REDIS_PORT=redis.falcon:6379 \
  39. $image_tag
  40. sleep 15
  41. ## start falcon backend modules, such as graph,api,etc.
  42. docker exec falcon-plus sh ctrl.sh start \
  43. graph hbs judge transfer nodata aggregator agent gateway api alarm
  44. echo "sleep 15s waiting for falcon-plus process ready..."
  45. sleep 15
  46. make test