70 lines
2.3 KiB
YAML
70 lines
2.3 KiB
YAML
kind: pipeline
|
||
type: docker
|
||
name: ${serverName} # 服务名成,可与jar包名保持一致
|
||
|
||
steps:
|
||
|
||
- name: maven-build
|
||
image: maven:3.8.5-openjdk-17
|
||
volumes:
|
||
- name: maven-cache
|
||
path: /root/.m2
|
||
- name: build-output
|
||
path: /home/app/build
|
||
commands:
|
||
- cd /drone/src
|
||
- mvn clean package -DskipTests=true -pl yudao-gateway,yudao-module-system/yudao-module-system-biz,yudao-module-infra/yudao-module-infra-biz -am
|
||
|
||
- name: copy-jars
|
||
image: alpine
|
||
volumes:
|
||
- name: build-output
|
||
path: /home/app/build
|
||
commands:
|
||
- mkdir -p /home/app/build/gateway
|
||
- mkdir -p /home/app/build/system
|
||
- mkdir -p /home/app/build/infra
|
||
- ls -l yudao-gateway/target/ # 检查源文件是否存在
|
||
- cp yudao-gateway/target/yudao-gateway.jar /home/app/build/gateway/app.jar || echo "Failed to copy gateway jar"
|
||
- cp yudao-module-system/yudao-module-system-biz/target/yudao-module-system-biz.jar /home/app/build/system/app.jar || echo "Failed to copy system biz jar"
|
||
- cp yudao-module-infra/yudao-module-infra-biz/target/yudao-module-infra-biz.jar /home/app/build/infra/app.jar || echo "Failed to copy infra biz jar"
|
||
- cp Dockerfile /home/app/build/
|
||
- cp docker-compose.yml /home/app/build/
|
||
|
||
- name: build-docker-images
|
||
image: docker
|
||
volumes:
|
||
- name: build-output
|
||
path: /home/app/build
|
||
- name: docker
|
||
path: /var/run/docker.sock
|
||
commands:
|
||
- cd /home/app/build
|
||
- cd gateway && docker build -t yudao-gateway:${APP_VERSION} -f ../Dockerfile .
|
||
- cd ../system && docker build -t yudao-module-system:${APP_VERSION} -f ../Dockerfile .
|
||
- cd ../infra && docker build -t yudao-module-infra:${APP_VERSION} -f ../Dockerfile .
|
||
|
||
- name: deploy-with-compose
|
||
image: docker/compose:1.29.2
|
||
environment:
|
||
APP_VERSION: ${APP_VERSION}
|
||
volumes:
|
||
- name: build-output
|
||
path: /home/app/build
|
||
- name: docker
|
||
path: /var/run/docker.sock
|
||
commands:
|
||
- cd /home/app/build
|
||
- sed -i "s/${APP_VERSION}/${APP_VERSION}/g" docker-compose.yml
|
||
- docker-compose -f docker-compose.yml up -d
|
||
|
||
volumes:
|
||
- name: maven-cache
|
||
host:
|
||
path: /home/data/maven/cache
|
||
- name: build-output
|
||
host:
|
||
path: /home/data/maven/build
|
||
- name: docker
|
||
host:
|
||
path: /var/run/docker.sock |