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

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

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

idea + Docker-Compose 实现自动化打包部署(仅限测试环境)_第1张图片

重启docker服务

systemctl daemon-reload
systemctl start docker

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

idea + Docker-Compose 实现自动化打包部署(仅限测试环境)_第2张图片

  1. Docker(Server)idea + Docker-Compose 实现自动化打包部署(仅限测试环境)_第3张图片
  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全部服务idea + Docker-Compose 实现自动化打包部署(仅限测试环境)_第4张图片

  4. 启动之前可以执行maven 的clean和package命令【clean package -Dmaven.test.skip=true -U】idea + Docker-Compose 实现自动化打包部署(仅限测试环境)_第5张图片

你可能感兴趣的:(docker,自动化,容器)