drone CICD 后端配置参考
部分说明可以参考 前端配置参考。
.drone.yml
kind: pipeline
name: default
volumes:
- name: .m2 # 缓存
host:
path: /tmp/.m2
steps:
- name: maven-build
image: maven:3.6.3
volumes:
- name: .m2
path: /root/.m2
commands:
- mvn clean package -DskipTests
- name: docker-build # 使用 dockerfile 打包成镜像, 并推送到镜像仓库
image: plugins/docker
settings:
registry: xxxxx.xxxxx.aliyuncs.com
repo: xxxxx.xxxxx.aliyuncs.com/xxxx/xxxxx
username:
from_secret: docker_username
password:
from_secret: docker_password
tags:
- latest
- ${DRONE_COMMIT}
- ${DRONE_TARGET_BRANCH}
- name: ssh-publish # 使用 ssh 在 服务器上进行发布
image: appleboy/drone-ssh
settings:
host:
- xxxx.xxxxx.cn # 要发布的服务器域名或IP
username: root
password:
from_secret: ssh_password
port: 22
command_timeout: 2m
script:
- cd /home/xxx
- docker-compose pull backend # 拉取上一步推送的镜像
- docker-compose up -d # 启动
Dockerfile
FROM openjdk:11.0.16-jre
COPY ./main/target/*.jar /app/app.jar
WORKDIR /app
EXPOSE 16666/tcp
ENTRYPOINT ["java","-jar","./app.jar"]