publish_docker_apple_silicon.sh 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. echo "A docker image release script for the Apple Silicon device."
  3. # -p:允许后面跟一个字符串作为提示 -r:保证读入的是原始内容,不会发生任何转义
  4. read -r -p "请输入Dockedr镜像版本:" version
  5. echo "即将构建的 server 镜像:powerjob-server:$version"
  6. echo "即将构建的 agent 镜像:powerjob-agent:$version"
  7. read -r -p "任意键继续:"
  8. # 一键部署脚本,请勿挪动脚本
  9. cd `dirname $0`/../.. || exit
  10. read -r -p "是否进行maven构建(y/n):" needmvn
  11. if [ "$needmvn" = "y" ] || [ "$needmvn" = "Y" ]; then
  12. echo "================== 构建 jar =================="
  13. # mvn clean package -Pdev -DskipTests -U -e -pl powerjob-server,powerjob-worker-agent -am
  14. # -U:强制检查snapshot库 -pl:指定需要构建的模块,多模块逗号分割 -am:同时构建依赖模块,一般与pl连用 -Pxxx:指定使用的配置文件
  15. mvn clean package -Pdev -DskipTests -U -e
  16. echo "================== 拷贝 jar =================="
  17. /bin/cp -rf powerjob-server/powerjob-server-starter/target/*.jar powerjob-server/docker/powerjob-server.jar
  18. /bin/cp -rf powerjob-worker-agent/target/*.jar powerjob-worker-agent/powerjob-agent.jar
  19. ls -l powerjob-server/docker/powerjob-server.jar
  20. ls -l powerjob-worker-agent/powerjob-agent.jar
  21. fi
  22. echo "================== 关闭老应用 =================="
  23. docker stop powerjob-server
  24. docker stop powerjob-agent
  25. docker stop powerjob-agent2
  26. echo "================== 删除老容器 =================="
  27. docker container rm powerjob-server
  28. docker container rm powerjob-agent
  29. docker container rm powerjob-agent2
  30. read -r -p "是否构建并发布镜像(y/n):" rebuild
  31. if [ "$rebuild" = "y" ] || [ "$rebuild" = "Y" ]; then
  32. echo "================== 删除旧镜像 =================="
  33. docker rmi -f tjqq/powerjob-server:$version
  34. docker rmi -f powerjob/powerjob-server:$version
  35. docker rmi -f tjqq/powerjob-agent:$version
  36. docker rmi -f powerjob/powerjob-agent:$version
  37. docker rmi -f powerjob/powerjob-mysql:$version
  38. docker rmi -f powerjob/powerjob-worker-samples:$version
  39. echo "================== 构建 powerjob-server 镜像(tjqq) =================="
  40. docker buildx build --platform=linux/amd64,linux/arm64 --tag tjqq/powerjob-server:$version powerjob-server/docker/. --push || exit
  41. echo "================== 构建 powerjob-server 镜像(powerjob) =================="
  42. docker buildx build --platform=linux/amd64,linux/arm64 --tag powerjob/powerjob-server:$version powerjob-server/docker/. --push || exit
  43. echo "================== 构建 powerjob-agent 镜像(tjqq) =================="
  44. docker buildx build --platform=linux/amd64,linux/arm64 --tag tjqq/powerjob-agent:$version powerjob-worker-agent/. --push|| exit
  45. echo "================== 构建 powerjob-agent 镜像(powerjob) =================="
  46. docker buildx build --platform=linux/amd64,linux/arm64 --tag powerjob/powerjob-agent:$version powerjob-worker-agent/. --push|| exit
  47. echo "================== 构建 powerjob-mysql 镜像 =================="
  48. docker buildx build --platform=linux/amd64,linux/arm64 --tag powerjob/powerjob-mysql:$version others/. --push|| exit
  49. echo "================== 构建 powerjob-worker-samples 镜像 =================="
  50. docker buildx build --platform=linux/amd64,linux/arm64 --tag powerjob/powerjob-worker-samples:$version powerjob-worker-samples/. --push|| exit
  51. fi
  52. read -r -p "是否推送LATEST(y/n):" push_latest
  53. if [ "$push_latest" = "y" ] || [ "$push_latest" = "Y" ]; then
  54. echo "================== powerjob-server LATEST (tjqq) =================="
  55. docker buildx build --platform=linux/amd64,linux/arm64 --tag tjqq/powerjob-server:latest powerjob-server/docker/. --push || exit
  56. echo "================== powerjob-server LATEST (powerjob) =================="
  57. docker buildx build --platform=linux/amd64,linux/arm64 --tag powerjob/powerjob-server:latest powerjob-server/docker/. --push || exit
  58. echo "================== powerjob-agent LATEST (tjqq) =================="
  59. docker buildx build --platform=linux/amd64,linux/arm64 --tag tjqq/powerjob-agent:latest powerjob-worker-agent/. --push|| exit
  60. echo "================== powerjob-agent LATEST (powerjob) =================="
  61. docker buildx build --platform=linux/amd64,linux/arm64 --tag powerjob/powerjob-agent:latest powerjob-worker-agent/. --push|| exit
  62. echo "================== powerjob-mysql LATEST =================="
  63. docker buildx build --platform=linux/amd64,linux/arm64 --tag powerjob/powerjob-mysql:latest others/. --push|| exit
  64. echo "================== powerjob-worker-samples LATEST =================="
  65. docker buildx build --platform=linux/amd64,linux/arm64 --tag powerjob/powerjob-worker-samples:latest powerjob-worker-samples/. --push|| exit
  66. fi