61 lines
1.7 KiB
YAML
61 lines
1.7 KiB
YAML
kind: pipeline
|
||
type: docker
|
||
name: myProject
|
||
|
||
steps:
|
||
# 1.maven打包
|
||
- name: maven compile
|
||
pull: if-not-exists
|
||
# 构建镜像的maven+jdk选择,最好选择满足匹配你的项目版本的
|
||
image: matderosa/maven-3.8-openjdk-17-gcc8.5
|
||
volumes:
|
||
# maven构建缓存
|
||
- name: maven-cache
|
||
path: /root/.m2
|
||
# 挂载宿主机的目录
|
||
- name: maven-build
|
||
path: /thirdPlatform/build
|
||
commands:
|
||
# 开始打包maven工程
|
||
- mvn clean package -Dmaven.test.skip=true
|
||
# 将打包后的文件复制到宿主机映射目录
|
||
- cp target/*.jar /thirdPlatform/build
|
||
- cp Dockerfile /thirdPlatform/build
|
||
- cp docker.sh /thirdPlatform/build
|
||
- cp start.sh /thirdPlatform/build
|
||
|
||
- name: build docker
|
||
image: plugins/docker
|
||
volumes:
|
||
# 将容器内目录挂载到宿主机,仓库需要开启Trusted设置
|
||
- name: maven-build
|
||
path: /thirdPlatform/build # 将应用打包好的Jar和执行脚本挂载出来
|
||
- name: docker
|
||
path: /var/run/docker.sock # 挂载宿主机的docker
|
||
settings:
|
||
dockerfile: /thirdPlatform/build/Dockerfile
|
||
commands:
|
||
# 定义在Docker容器中执行的shell命令
|
||
- cd /thirdPlatform/build
|
||
- chmod +x docker.sh
|
||
- sh docker.sh
|
||
- docker ps
|
||
|
||
|
||
volumes: # 定义流水线挂载目录,用于共享数据
|
||
- name: maven-build
|
||
host:
|
||
path: /home/projects/thirdPlatform/maven/build # 从宿主机中挂载的目录
|
||
- name: maven-cache
|
||
host:
|
||
path: /home/projects/thirdPlatform/maven/cache
|
||
- name: docker
|
||
host:
|
||
path: /var/run/docker.sock
|
||
|
||
|
||
# drone执行触发器
|
||
trigger:
|
||
branch:
|
||
- master
|