idea + Docker-Compose 实现自动化打包部署(仅限测试环境)

一、修改docker.service文件,添加监听端口

bash 复制代码
vi /usr/lib/systemd/system/docker.service
bash 复制代码
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock

重启docker服务

bash 复制代码
systemctl daemon-reload
systemctl start docker

二、idea的docker-compose启动配置(分四步)

  1. Docker(Server)

  2. docker-compose.yml

    version : '3.9'
    services:
      ruoyi-gateway-test:
        #image: ruoyi/ruoyi-gateway:1.0.0
        container_name: ruoyi-gateway-test
        build:
          context: ../ruoyi-gateway
          dockerfile: Dockerfile
        environment:
          # 时区上海
          TZ: Asia/Shanghai
        volumes:
          # 配置文件
          - /docker/zj-cloud/logs/ruoyi-gateway/:/ruoyi/ruoyi-gateway/logs/
        ports:
          - "8889:8889"
        command: [
          "--server.port=8889"
        ]
        privileged: true
        network_mode: "host"
        restart: always
      ruoyi-auth-test:
        #image: ruoyi/ruoyi-auth:1.0.0
        container_name: ruoyi-auth-test
        build:
          context: ../ruoyi-auth
          dockerfile: Dockerfile
        ports:
          - "9299:9299"
        volumes:
          # 配置文件
          - /docker/zj-cloud/logs/ruoyi-auth/:/ruoyi/ruoyi-auth/logs/
        privileged: true
        network_mode: "host"
        restart: always
      ruoyi-modules-system-man-test:
        #image: ruoyi/ruoyi-modules-system-man:1.0.0
        container_name: ruoyi-modules-system-man-test
        build:
          context: ../ruoyi-modules/ruoyi-system-man
          dockerfile: Dockerfile
        environment:
          # 时区上海
          TZ: Asia/Shanghai
        volumes:
          # 配置文件
          - /docker/zj-cloud/logs/ruoyi-modules-system-man/:/ruoyi/ruoyi-modules-system-man/logs
        ports:
          - "9399:9399"
        privileged: true
        network_mode: "host"
        restart: always
      ruoyi-modules-system-ops-test:
        #image: ruoyi/ruoyi-modules-system-ops:1.0.0
        container_name: ruoyi-modules-system-ops-test
        build:
          context: ../ruoyi-modules/ruoyi-system-ops
          dockerfile: Dockerfile
        environment:
          # 时区上海
          TZ: Asia/Shanghai
        volumes:
          # 配置文件
          - /docker/zj-cloud/logs/ruoyi-modules-system-ops/:/ruoyi/ruoyi-modules-system-ops/logs
        ports:
          - "9499:9499"
        privileged: true
        network_mode: "host"
        restart: always
      ruoyi-modules-man-test:
        #image: ruoyi/ruoyi-modules-system-ops:1.0.0
        container_name: ruoyi-modules-man-test
        build:
          context: ../ruoyi-modules/ruoyi-man
          dockerfile: Dockerfile
        environment:
          # 时区上海
          TZ: Asia/Shanghai
        volumes:
          # 配置文件
          - /docker/zj-cloud/logs/ruoyi-modules-man/:/ruoyi/ruoyi-modules-man/logs
        ports:
          - "9302:9302"
        privileged: true
        network_mode: "host"
        restart: always
      ruoyi-modules-ops-test:
        #image: ruoyi/ruoyi-modules-system-ops:1.0.0
        container_name: ruoyi-modules-ops-test
        build:
          context: ../ruoyi-modules/ruoyi-ops
          dockerfile: Dockerfile
        environment:
          # 时区上海
          TZ: Asia/Shanghai
        volumes:
          # 配置文件
          - /docker/zj-cloud/logs/ruoyi-modules-ops/:/ruoyi/ruoyi-modules-ops/logs
        ports:
          - "9301:9301"
        privileged: true
        network_mode: "host"
        restart: always
    
  3. 命令,一定要勾选build,每次尽量重新构建镜像,同时如果需要单独启动/build某几个服务,就只需要输入对应服务名,逗号隔开,为空则时启动/build全部服务

  4. 启动之前可以执行maven 的clean和package命令【clean package -Dmaven.test.skip=true -U】

相关推荐
景天科技苑3 小时前
【云原生开发】K8S多集群资源管理平台架构设计
云原生·容器·kubernetes·k8s·云原生开发·k8s管理系统
wclass-zhengge3 小时前
K8S篇(基本介绍)
云原生·容器·kubernetes
颜淡慕潇3 小时前
【K8S问题系列 |1 】Kubernetes 中 NodePort 类型的 Service 无法访问【已解决】
后端·云原生·容器·kubernetes·问题解决
川石课堂软件测试5 小时前
性能测试|docker容器下搭建JMeter+Grafana+Influxdb监控可视化平台
运维·javascript·深度学习·jmeter·docker·容器·grafana
flashman9116 小时前
python在word中插入图片
python·microsoft·自动化·word
昌sit!12 小时前
K8S node节点没有相应的pod镜像运行故障处理办法
云原生·容器·kubernetes
追风林13 小时前
mac 本地docker-mysql主从复制部署
mysql·macos·docker
A ?Charis14 小时前
Gitlab-runner running on Kubernetes - hostAliases
容器·kubernetes·gitlab
城南vision14 小时前
Docker学习—Docker核心概念总结
java·学习·docker
wclass-zhengge15 小时前
Docker篇(Docker Compose)
运维·docker·容器