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

93 lines
2.8 KiB

2 years ago
kind: pipeline
type: docker
name: master
steps:
2 years ago
- name: restore-cache
image: meltwater/drone-cache
settings:
backend: filesystem
restore: true
cache_key: "maven"
archive_format: gzip
filesystem_cache_root: "/var/lib/cache"
mount:
- "maven"
volumes:
- name: cache
path: "/var/lib/cache"
# Do stuff..
- name: build
image: maven:3.8-openjdk-8
2 years ago
volumes: # 将容器内目录挂载到宿主机仓库需要开启Trusted设置
- name: maven-build
path: /app/build # 将应用打包好的Jar和执行脚本挂载出来
2 years ago
commands:
- mkdir /root/.m2
- cp /usr/share/maven/ref/settings-docker.xml /root/.m2/settings.xml
- sed -i 's/\\/usr\\/share\\/maven\\/ref\\/repository/\\/drone\\/src\\/maven/g' /root/.m2/settings.xml
- mvn package
2 years ago
- cp target/lingnuo-0.0.1.jar /app/build/lingnuo-0.0.1.jar
2 years ago
- cp Dockerfile /app/build/Dockerfile
- cp run.sh /app/build/run.sh
2 years ago
- name: rebuild-cache
image: meltwater/drone-cache
settings:
backend: filesystem
rebuild: true
cache_key: "maven"
archive_format: gzip
filesystem_cache_root: "/var/lib/cache"
mount:
- "maven"
volumes:
- name: cache
path: "/var/lib/cache"
2 years ago
# - name: scp files
# image: appleboy/drone-scp
# settings:
# host: 121.41.171.43
# username:
# from_secret: linac
# password:
# from_secret: linac
# port: 22
# target: /root
# source: /target/*
2 years ago
- name: ssh
image: appleboy/drone-ssh
settings:
host: 121.41.171.43
2 years ago
username:
2 years ago
from_secret: linac_user
2 years ago
password:
2 years ago
from_secret: linac_secreat
2 years ago
port: 22
command_timeout: 5m
script:
2 years ago
- cd /data/wwwroot/docker/maven/build # 进入宿主机构建目录
2 years ago
- chmod +x run.sh # 更改为可执行脚本
- ./run.sh # 运行脚本打包应用镜像并运行
# - name: docker
# image: plugins/docker
# settings:
# dockerfile: "Dockerfile"
# username:
# from_secret: docker_username
# password:
# from_secret: docker_password
# tags:
# - master
2 years ago
volumes: # 定义流水线挂载目录,用于共享数据
- name: maven-build
host:
path: /data/wwwroot/docker/maven/build # 从宿主机中挂载的目录
2 years ago
- name: cache
host:
path: "/var/lib/cache"
2 years ago
trigger:
2 years ago
branch:
- master
event:
- push
- merge