You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.6 KiB
YAML

kind: pipeline
type: docker
name: venue_reservation_service
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: /venue/build
commands:
# 开始打包maven工程
- mvn clean package -Dmaven.test.skip=true
# 将打包后的文件复制到宿主机映射目录
- cp target/*.jar /venue/build
- cp Dockerfile /venue/build
- cp docker.sh /venue/build
- name: build docker
image: plugins/docker
volumes:
# 将容器内目录挂载到宿主机仓库需要开启Trusted设置
- name: maven-build
path: /venue/build # 将应用打包好的Jar和执行脚本挂载出来
- name: docker
path: /var/run/docker.sock # 挂载宿主机的docker
settings:
dockerfile: /venue/build/Dockerfile
commands:
# 定义在Docker容器中执行的shell命令
- cd /venue/build
- chmod +x docker.sh
- sh docker.sh
- docker ps
volumes: # 定义流水线挂载目录,用于共享数据
- name: maven-build
host:
path: /home/projects/venue/maven/build # 从宿主机中挂载的目录
- name: maven-cache
host:
path: /home/projects/venue/maven/cache
- name: docker
host:
path: /var/run/docker.sock
# drone执行触发器
trigger:
branch:
- master