ZeroErrOACloud-Drone-Java/zeroerroa-gateway/.drone.yml

61 lines
1.8 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

kind: pipeline
type: docker
name: gateway
steps:
# 1.maven打包
- name: maven compile
pull: if-not-exists
# 构建镜像的maven+jdk选择最好选择满足匹配你的项目版本的;这里的maven是maven3
image: adoptopenjdk/maven-openjdk8
volumes:
# maven构建缓存也就是下面的/home/zeroerr/drone/maven/cache
- name: maven-cache
path: /root/.m2
# 挂载宿主机的目录;也就是下面的/home/zeroerr/drone/maven/build
- name: maven-build
path: /drone/gateway
commands:
# 开始打包maven工程
- mvn clean package -Dmaven.test.skip=true
# 将打包后的文件复制到宿主机映射目录.
- cp target/*.jar /drone/gateway
- cp Dockerfile /drone/gateway
- cp docker.sh /drone/gateway
- cp start.sh /drone/gateway
- name: build docker
image: plugins/docker
volumes:
# 将容器内目录挂载到宿主机仓库需要开启Trusted设置
- name: maven-build
path: /drone/gateway # 将应用打包好的Jar和执行脚本挂载出来
- name: docker
path: /var/run/docker.sock # 挂载宿主机的docker
settings:
dockerfile: /drone/gateway/Dockerfile #这里的Dockerfile就是项目根目录里的Dockerfile必须保证名字和内容无误
commands:
# 定义在Docker容器中执行的shell命令
- cd /drone/gateway
- chmod +x docker.sh
- sh docker.sh
- docker ps
volumes: # 定义流水线挂载目录,用于共享数据
- name: maven-build
host:
path: /home/zeroerr/drone/maven/gateway # 从宿主机中挂载的目录
- name: maven-cache
host:
path: /home/zeroerr/drone/maven/cache # 从宿主机中挂载的目录
- name: docker
host:
path: /var/run/docker.sock
# drone执行触发器
trigger:
branch:
- master