jenkins_auto_build.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. cd `dirname $0`/../.. || exit
  3. echo "================== 构建 jar =================="
  4. mvn clean package -Pdev -DskipTests -e
  5. echo "================== 拷贝 jar =================="
  6. /bin/cp -rf powerjob-server/powerjob-server-starter/target/*.jar powerjob-server/docker/powerjob-server.jar
  7. echo "================== 关闭老应用 =================="
  8. docker stop powerjob-server
  9. docker stop powerjob-worker-samples
  10. docker stop powerjob-worker-samples2
  11. echo "================== 删除老容器 =================="
  12. docker container rm powerjob-server
  13. docker container rm powerjob-worker-samples
  14. docker container rm powerjob-worker-samples2
  15. echo "================== 删除旧镜像 =================="
  16. docker rmi -f tjqq/powerjob-server:latest
  17. docker rmi -f tjqq/powerjob-worker-samples:latest
  18. echo "================== 构建 powerjob-server 镜像 =================="
  19. docker build -t tjqq/powerjob-server:latest powerjob-server/docker/. || exit
  20. echo "================== 构建 powerjob-worker-samples 镜像 =================="
  21. docker build -t tjqq/powerjob-worker-samples:latest powerjob-worker-samples/. || exit
  22. echo "================== 准备启动 powerjob-server =================="
  23. docker run -d \
  24. --restart=always \
  25. --name powerjob-server \
  26. -p 7700:7700 -p 10086:10086 -p 5001:5005 -p 10001:10000 \
  27. -e JVMOPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10000 -Dcom.sun.management.jmxremote.rmi.port=10000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" \
  28. -e PARAMS="--oms.swagger.enable=true --spring.profiles.active=product --spring.datasource.core.jdbc-url=jdbc:mysql://remotehost:3306/powerjob-product?useUnicode=true&characterEncoding=UTF-8 --oms.mongodb.enable=false --spring.data.mongodb.uri=mongodb://remotehost:27017/powerjob-product" \
  29. -v ~/docker/powerjob-server:/root/powerjob/server -v ~/.m2:/root/.m2 \
  30. tjqq/powerjob-server:latest
  31. sleep 60
  32. echo "================== 准备启动 powerjob-agent =================="
  33. serverIP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' powerjob-server)
  34. serverAddress="$serverIP:7700"
  35. echo "使用的Server地址:$serverAddress"
  36. docker run -d \
  37. --restart=always \
  38. --name powerjob-worker-samples \
  39. -p 27777:27777 -p 5002:5005 -p 10002:10000 \
  40. -e JVMOPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10000 -Dcom.sun.management.jmxremote.rmi.port=10000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" \
  41. -e PARAMS="--powerjob.worker.server-address=$serverAddress" \
  42. -v ~/docker/powerjob-worker-samples:/root \
  43. tjqq/powerjob-worker-samples:latest
  44. docker run -d \
  45. --restart=always \
  46. --name powerjob-worker-samples2 \
  47. -p 27778:27777 -p 5003:5005 -p 10003:10000 \
  48. -e JVMOPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10000 -Dcom.sun.management.jmxremote.rmi.port=10000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" \
  49. -e PARAMS="--powerjob.worker.server-address=$serverAddress" \
  50. -v ~/docker/powerjob-worker-samples2:/root \
  51. tjqq/powerjob-worker-samples:latest