45 lines
1.6 KiB
YAML
45 lines
1.6 KiB
YAML
kind: pipeline
|
||
type: docker
|
||
name: game
|
||
|
||
steps:
|
||
- name: build-jar # 流水线名称
|
||
image: maven:3.8.5-openjdk-8 # 定义创建容器的Docker镜像
|
||
volumes: # 将容器内目录挂载到宿主机,仓库需要开启Trusted设置
|
||
- name: maven-cache
|
||
path: /root/.m2 # 将maven下载依赖的目录挂载出来,防止重复下载
|
||
- name: maven-build
|
||
path: /app/build # 将应用打包好的Jar和执行脚本挂载出来
|
||
commands: # 定义在Docker容器中执行的shell命令
|
||
- mvn clean package -DskipTests=true # 应用打包命
|
||
- cp target/game.jar /app/build/game.jar
|
||
- cp Dockerfile /app/build/
|
||
- cp run.sh /app/build/
|
||
- name: build-docker # 流水线名称
|
||
image: plugins/docker
|
||
volumes: # 将容器内目录挂载到宿主机,仓库需要开启Trusted设置
|
||
- name: maven-build
|
||
path: /app/build # 将应用打包好的Jar和执行脚本挂载出来
|
||
- name: docker
|
||
path: /var/run/docker.sock # 挂载宿主机的docker
|
||
settings:
|
||
dockerfile: /app/build/Dockerfile
|
||
commands: # 定义在Docker容器中执行的shell命令
|
||
- cd /app/build
|
||
- chmod +x run.sh
|
||
- sh run.sh
|
||
- docker ps
|
||
volumes: # 定义流水线挂载目录,用于共享数据
|
||
- name: maven-build
|
||
host:
|
||
path: /home/docker/drone/maven/build # 从宿主机中挂载的目录
|
||
- name: maven-cache
|
||
host:
|
||
path: /home/docker/drone/maven/cache
|
||
- name: docker
|
||
host:
|
||
path: /var/run/docker.sock
|
||
|
||
|
||
# 链接:https://juejin.cn/post/7153173983335022605
|