构建新增镜像方式

This commit is contained in:
XinWei 2024-09-13 10:44:33 +08:00
parent 4c3d9c7878
commit 894f8bf8c3
2 changed files with 238 additions and 95 deletions

145
.drone-images.yml Normal file
View File

@ -0,0 +1,145 @@
kind: pipeline # 定义对象类型还有secret和signature两种类型
type: docker # 定义流水线类型还有kubernetes、exec、ssh等类型
name: ludu-drone-images # 定义流水线名称
steps: # 定义流水线执行步骤,这些步骤将顺序执行
- name: package # 流水线名称
image: maven:3-jdk-8 # 定义创建容器的Docker镜像
volumes: # 将容器内目录挂载到宿主机仓库需要开启Trusted设置
- name: maven-cache
path: /root/.m2 # 将maven下载依赖的目录挂载出来防止重复下载
- name: maven-build
path: /app/build # 将应用打包好的Jar和执行脚本挂载出来
commands: # 定义在Docker容器中执行的shell命令
- mvn package -Dmaven.test.skip=true # 应用打包命令
- |
if [ "${service}" = "gateway" ] || [ "${service}" = "all" ]; then
cp ./yudao-gateway/target/yudao-gateway.jar /app/build/yudao-gateway/target
cp ./yudao-gateway/Dockerfile /app/build/yudao-gateway
cp ./yudao-gateway/run.sh /app/build/yudao-gateway
fi
if [ "${service}" = "system" ] || [ "${service}" = "all" ]; then
cp ./yudao-module-system/yudao-module-system-biz/target/yudao-module-system-biz.jar /app/build/yudao-module-system/target
cp ./yudao-module-system/yudao-module-system-biz/Dockerfile /app/build/yudao-module-system
cp ./yudao-module-system/yudao-module-system-biz/run.sh /app/build/yudao-module-system
fi
if [ "${service}" = "infra" ] || [ "${service}" = "all" ]; then
cp ./yudao-module-infra/yudao-module-infra-biz/target/yudao-module-infra-biz.jar /app/build/yudao-module-infra/target
cp ./yudao-module-infra/yudao-module-infra-biz/Dockerfile /app/build/yudao-module-infra
cp ./yudao-module-infra/yudao-module-infra-biz/run.sh /app/build/yudao-module-infra
fi
if [ "${service}" = "job" ] || [ "${service}" = "all" ]; then
cp ./ludu-job-admin/ludu-job-admin-biz/target/ludu-job-admin-biz.jar /app/build/ludu-job-admin/target
cp ./ludu-job-admin/ludu-job-admin-biz/Dockerfile /app/build/ludu-job-admin
cp ./ludu-job-admin/ludu-job-admin-biz/run.sh /app/build/ludu-job-admin
fi
if [ "${service}" = "ticketing" ] || [ "${service}" = "all" ]; then
cp ./ludu-module-ticketing/ludu-module-ticketing-biz/target/ludu-module-ticketing-biz.jar /app/build/ludu-module-ticketing/target
cp ./ludu-module-ticketing/ludu-module-ticketing-biz/Dockerfile /app/build/ludu-module-ticketing
cp ./ludu-module-ticketing/ludu-module-ticketing-biz/run.sh /app/build/ludu-module-ticketing
fi
if [ "${service}" = "parking" ] || [ "${service}" = "all" ]; then
cp ./ludu-module-parking/ludu-module-parking-biz/target/ludu-module-parking-biz.jar /app/build/ludu-module-parking/target
cp ./ludu-module-parking/ludu-module-parking-biz/Dockerfile /app/build/ludu-module-parking
cp ./ludu-module-parking/ludu-module-parking-biz/run.sh /app/build/ludu-module-parking
fi
if [ "${service}" = "datacenter" ] || [ "${service}" = "all" ]; then
cp ./ludu-module-datacenter/ludu-module-datacenter-biz/target/ludu-module-datacenter-biz.jar /app/build/ludu-module-datacenter/target
cp ./ludu-module-datacenter/ludu-module-datacenter-biz/Dockerfile /app/build/ludu-module-datacenter
cp ./ludu-module-datacenter/ludu-module-datacenter-biz/run.sh /app/build/ludu-module-datacenter
fi
- name: push-images
image: appleboy/drone-ssh # SSH工具镜像
settings:
host: 101.43.112.107 # 远程连接地址
username: root # 远程连接账号
password:
from_secret: ssh_password # 从Secret中读取SSH密码
port: 22 # 远程连接端口
command_timeout: 30m # 远程执行命令超时时间
script:
- |
deploy_service() {
local image_name=$1
local container_name=$2
cd /ludu/build/${image_name}
docker stop ${container_name}
docker rm ${container_name}
docker rmi -f ${image_name}:1.0.0
docker buildx build -f Dockerfile -t ${image_name}:1.0.0 .
docker tag ${image_name}:1.0.0 120.46.37.243:8080/lundu/${image_name}:1.0.0
docker pull 120.46.37.243:8080/lundu/${image_name}:1.0.0
}
if [ "${service}" = "gateway" ] || [ "${service}" = "all" ]; then
deploy_service "yudao-gateway" "yudao-gateway"
fi
if [ "${service}" = "system" ] || [ "${service}" = "all" ]; then
deploy_service "yudao-module-system" "yudao-system"
fi
if [ "${service}" = "infra" ] || [ "${service}" = "all" ]; then
deploy_service "yudao-module-infra" "yudao-infra"
fi
if [ "${service}" = "job" ] || [ "${service}" = "all" ]; then
deploy_service "ludu-job-admin" "ludu-job-admin"
fi
if [ "${service}" = "ticketing" ] || [ "${service}" = "all" ]; then
deploy_service "ludu-module-ticketing" "ludu-ticketing"
fi
if [ "${service}" = "parking" ] || [ "${service}" = "all" ]; then
deploy_service "ludu-module-parking" "ludu-parking"
fi
if [ "${service}" = "datacenter" ] || [ "${service}" = "all" ]; then
deploy_service "ludu-module-datacenter" "ludu-datacenter"
fi
- name: pull-image-and-run
image: appleboy/drone-ssh # SSH工具镜像
settings:
host: 121.36.203.133 # 远程连接地址
username: root # 远程连接账号
password:
from_secret: ssh_password3 # 从Secret中读取SSH密码
port: 22 # 远程连接端口
command_timeout: 20m # 远程执行命令超时时间
script:
- cd /ludu
- ./start_service.sh ${service}
volumes: # 定义流水线挂载目录,用于共享数据
- name: maven-build
host:
path: /ludu/build # 从宿主机中挂载的目录
- name: maven-cache
host:
path: /ludu/cache # 从宿主机中挂载的目录

View File

@ -1,68 +1,82 @@
version: '3' version: '3.8'
services: services:
yudao-gateway: yudao-gateway:
image: yudao-gateway image: 120.46.37.243:8080/lundu/yudao-gateway:1.0.0
container_name: yudao-gateway container_name: yudao-gateway
networks:
- ludu_network
environment: environment:
- TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间) - TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间)
- JAVA_TOOL_OPTIONS=-javaagent:/data/skywalking/skywalking-agent/skywalking-agent.jar # 配置skywalking
- SW_AGENT_NAME=yudao-gateway - SW_AGENT_NAME=yudao-gateway
- SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/** - SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/**
- SW_AGENT_COLLECTOR_BACKEND_SERVICES=[YOUR_SKYWALKING_ADDR] # 请替换 your.skywalking.addr 为你的 skywalking 地址
- SPRING_PROFILES_ACTIVE=test # 指定程序运行环境
- SPRING_CLOUD_NACOS_CONFIG_SERVER_ADDR=[YOUR_NACOS_ADDR] # 配置中心地址
- SPRING_CLOUD_NACOS_CONFIG_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
- SPRING_CLOUD_NACOS_SERVER_ADDR=[YOUR_NACOS_ADDR] # 注册中心地址
- SPRING_CLOUD_NACOS_DISCOVERY_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
volumes: volumes:
- /docker/yudao-cloud/logs:/root/logs/ - /docker/yudao-cloud/logs:/root/logs/
- /data/skywalking/skywalking-agent:/data/skywalking/skywalking-agent
restart: always restart: always
network_mode: host # 以主机网络环境运行 healthcheck:
test: [ "CMD","curl","-f","http://localhost:48080" ]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
ports:
- "48083:48080"
yudao-system: yudao-system:
image: yudao-module-system-biz image: 120.46.37.243:8080/lundu/yudao-module-system:1.0.0
container_name: yudao-system container_name: yudao-system
networks:
- ludu_network
environment: environment:
- TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间) - TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间)
- JAVA_TOOL_OPTIONS=-javaagent:/data/skywalking/skywalking-agent/skywalking-agent.jar # 配置skywalking
- SW_AGENT_NAME=yudao-gateway - SW_AGENT_NAME=yudao-gateway
- SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/** - SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/**
- SW_AGENT_COLLECTOR_BACKEND_SERVICES=[YOUR_SKYWALKING_ADDR] # 请替换 your.skywalking.addr 为你的 skywalking 地址
- SPRING_PROFILES_ACTIVE=test # 指定程序运行环境
- SPRING_CLOUD_NACOS_CONFIG_SERVER_ADDR=[YOUR_NACOS_ADDR] # 配置中心地址
- SPRING_CLOUD_NACOS_CONFIG_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
- SPRING_CLOUD_NACOS_SERVER_ADDR=[YOUR_NACOS_ADDR] # 注册中心地址
- SPRING_CLOUD_NACOS_DISCOVERY_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
volumes: volumes:
- /docker/yudao-cloud/logs:/root/logs/ - /docker/yudao-cloud/logs:/root/logs/
- /data/skywalking/skywalking-agent:/data/skywalking/skywalking-agent
healthcheck: healthcheck:
test: [ "CMD","curl","-f","http://localhost:48081" ] test: [ "CMD","curl","-f","http://localhost:48081" ]
interval: 30s interval: 30s
timeout: 10s timeout: 10s
retries: 5 retries: 5
start_period: 60s start_period: 120s
restart: always restart: always
network_mode: host depends_on:
yudao-infra: yudao-gateway:
image: yudao-module-infra-biz condition: service_healthy
container_name: yudao-infra ludu-job-admin:
image: 120.46.37.243:8080/lundu/ludu-job-admin:1.0.0
container_name: ludu-job-admin
networks:
- ludu_network
environment:
- TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间)
- SW_AGENT_NAME=yudao-gateway
- SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/**
volumes:
- /docker/yudao-cloud/logs:/root/logs/
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:9090 || exit 0"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
restart: always
ports:
- "48084:9090"
depends_on:
yudao-gateway:
condition: service_healthy
yudao-infra:
image: 120.46.37.243:8080/lundu/yudao-module-infra:1.0.0
container_name: yudao-infra
networks:
- ludu_network
environment: environment:
- TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间) - TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间)
- JAVA_TOOL_OPTIONS=-javaagent:/data/skywalking/skywalking-agent/skywalking-agent.jar # 配置skywalking
- SW_AGENT_NAME=yudao-gateway - SW_AGENT_NAME=yudao-gateway
- SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/** - SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/**
- SW_AGENT_COLLECTOR_BACKEND_SERVICES=[YOUR_SKYWALKING_ADDR] # 请替换 your.skywalking.addr 为你的 skywalking 地址
- SPRING_PROFILES_ACTIVE=test # 指定程序运行环境
- SPRING_CLOUD_NACOS_CONFIG_SERVER_ADDR=[YOUR_NACOS_ADDR] # 配置中心地址
- SPRING_CLOUD_NACOS_CONFIG_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
- SPRING_CLOUD_NACOS_SERVER_ADDR=[YOUR_NACOS_ADDR] # 注册中心地址
- SPRING_CLOUD_NACOS_DISCOVERY_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
volumes: volumes:
- /docker/yudao-cloud/logs:/root/logs/ - /docker/yudao-cloud/logs:/root/logs/
- /data/skywalking/skywalking-agent:/data/skywalking/skywalking-agent
restart: always restart: always
network_mode: host
healthcheck: healthcheck:
test: [ "CMD","curl","-f","http://localhost:48082" ] test: [ "CMD","curl","-f","http://localhost:48082" ]
interval: 30s interval: 30s
@ -72,91 +86,75 @@ services:
depends_on: depends_on:
yudao-system: yudao-system:
condition: service_healthy condition: service_healthy
yudao-report: yudao-gateway:
image: yudao-module-report-biz condition: service_healthy
container_name: yudao-report ludu-datacenter:
image: 120.46.37.243:8080/lundu/ludu-module-datacenter:1.0.0
container_name: ludu-datacenter
networks:
- ludu_network
environment: environment:
- TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间) - TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间)
- JAVA_TOOL_OPTIONS=-javaagent:/data/skywalking/skywalking-agent/skywalking-agent.jar # 配置skywalking
- SW_AGENT_NAME=yudao-gateway - SW_AGENT_NAME=yudao-gateway
- SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/** - SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/**
- SW_AGENT_COLLECTOR_BACKEND_SERVICES=[YOUR_SKYWALKING_ADDR] # 请替换 your.skywalking.addr 为你的 skywalking 地址
- SPRING_PROFILES_ACTIVE=test # 指定程序运行环境
- SPRING_CLOUD_NACOS_CONFIG_SERVER_ADDR=[YOUR_NACOS_ADDR] # 配置中心地址
- SPRING_CLOUD_NACOS_CONFIG_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
- SPRING_CLOUD_NACOS_SERVER_ADDR=[YOUR_NACOS_ADDR] # 注册中心地址
- SPRING_CLOUD_NACOS_DISCOVERY_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
volumes: volumes:
- /docker/yudao-cloud/logs:/root/logs/ - /docker/yudao-cloud/logs:/root/logs/
- /data/skywalking/skywalking-agent:/data/skywalking/skywalking-agent
restart: always restart: always
network_mode: host healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:48092 || exit 0"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
depends_on: depends_on:
yudao-infra: yudao-gateway:
condition: service_healthy condition: service_healthy
yudao-bpm: ludu-parking:
image: yudao-module-bpm-biz image: 120.46.37.243:8080/lundu/ludu-module-parking:1.0.0
container_name: yudao-bpm container_name: ludu-parking
networks:
- ludu_network
environment: environment:
- TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间) - TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间)
- JAVA_TOOL_OPTIONS=-javaagent:/data/skywalking/skywalking-agent/skywalking-agent.jar # 配置skywalking
- SW_AGENT_NAME=yudao-gateway - SW_AGENT_NAME=yudao-gateway
- SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/** - SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/**
- SW_AGENT_COLLECTOR_BACKEND_SERVICES=[YOUR_SKYWALKING_ADDR] # 请替换 your.skywalking.addr 为你的 skywalking 地址
- SPRING_PROFILES_ACTIVE=test # 指定程序运行环境
- SPRING_CLOUD_NACOS_CONFIG_SERVER_ADDR=[YOUR_NACOS_ADDR] # 配置中心地址
- SPRING_CLOUD_NACOS_CONFIG_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
- SPRING_CLOUD_NACOS_SERVER_ADDR=[YOUR_NACOS_ADDR] # 注册中心地址
- SPRING_CLOUD_NACOS_DISCOVERY_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
volumes: volumes:
- /docker/yudao-cloud/logs:/root/logs/ - /docker/yudao-cloud/logs:/root/logs/
- /data/skywalking/skywalking-agent:/data/skywalking/skywalking-agent
restart: always restart: always
network_mode: host healthcheck:
test: [ "CMD","curl","-f","http://localhost:48090" ]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
depends_on: depends_on:
yudao-infra: yudao-system:
condition: service_healthy condition: service_healthy
yudao-pay: yudao-gateway:
image: yudao-module-pay-biz condition: service_healthy
container_name: yudao-pay ludu-ticketing:
image: 120.46.37.243:8080/lundu/ludu-module-ticketing:1.0.0
container_name: ludu-ticketing
networks:
- ludu_network
environment: environment:
- TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间) - TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间)
- JAVA_TOOL_OPTIONS=-javaagent:/data/skywalking/skywalking-agent/skywalking-agent.jar # 配置skywalking
- SW_AGENT_NAME=yudao-gateway - SW_AGENT_NAME=yudao-gateway
- SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/** - SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/**
- SW_AGENT_COLLECTOR_BACKEND_SERVICES=[YOUR_SKYWALKING_ADDR] # 请替换 your.skywalking.addr 为你的 skywalking 地址
- SPRING_PROFILES_ACTIVE=test # 指定程序运行环境
- SPRING_CLOUD_NACOS_CONFIG_SERVER_ADDR=[YOUR_NACOS_ADDR] # 配置中心地址
- SPRING_CLOUD_NACOS_CONFIG_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
- SPRING_CLOUD_NACOS_SERVER_ADDR=[YOUR_NACOS_ADDR] # 注册中心地址
- SPRING_CLOUD_NACOS_DISCOVERY_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
volumes: volumes:
- /docker/yudao-cloud/logs:/root/logs/ - /docker/yudao-cloud/logs:/root/logs/
- /data/skywalking/skywalking-agent:/data/skywalking/skywalking-agent
restart: always restart: always
network_mode: host healthcheck:
test: [ "CMD","curl","-f","http://localhost:48088" ]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
depends_on: depends_on:
yudao-infra: yudao-system:
condition: service_healthy condition: service_healthy
yudao-mp: yudao-gateway:
image: yudao-module-mp-biz
container_name: yudao-mp
environment:
- TZ=Asia/Shanghai # 配置程序默认时区为上海(中国标准时间)
- JAVA_TOOL_OPTIONS=-javaagent:/data/skywalking/skywalking-agent/skywalking-agent.jar # 配置skywalking
- SW_AGENT_NAME=yudao-gateway
- SW_AGENT_TRACE_IGNORE_PATH=Redisson/PING,/actuator/**,/admin/**
- SW_AGENT_COLLECTOR_BACKEND_SERVICES=[YOUR_SKYWALKING_ADDR] # 请替换 your.skywalking.addr 为你的 skywalking 地址
- SPRING_PROFILES_ACTIVE=test # 指定程序运行环境
- SPRING_CLOUD_NACOS_CONFIG_SERVER_ADDR=[YOUR_NACOS_ADDR] # 配置中心地址
- SPRING_CLOUD_NACOS_CONFIG_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
- SPRING_CLOUD_NACOS_SERVER_ADDR=[YOUR_NACOS_ADDR] # 注册中心地址
- SPRING_CLOUD_NACOS_DISCOVERY_NAMESPACE=[YOUR_NAMESPACE] # 命名空间
volumes:
- /docker/yudao-cloud/logs:/root/logs/
- /data/skywalking/skywalking-agent:/data/skywalking/skywalking-agent
restart: always
network_mode: host
depends_on:
yudao-infra:
condition: service_healthy condition: service_healthy
networks:
ludu_network:
driver: bridge