80 lines
2.7 KiB
YAML
80 lines
2.7 KiB
YAML
# 第 81 次部署
|
||
# 💡 全局变量块
|
||
variables:
|
||
- &APP_REGISTRY "push.lovestory.cyou"
|
||
- &APP_PULL_REGISTRY "registry.lovestory.cyou"
|
||
- &PROJECT_NAME "abhors/demo"
|
||
- &CONTAINER_NAME "demo-container"
|
||
- &DEPLOY_HOST "43.143.243.136"
|
||
- &DEPLOY_PORT "22"
|
||
- &DEPLOY_USER_SECRET "136_ssh_user"
|
||
- &DEPLOY_PASS_SECRET "136_ssh_password"
|
||
|
||
steps:
|
||
- name: Java 构建
|
||
image: library/maven:3.9.6-eclipse-temurin-17
|
||
pull: true
|
||
commands:
|
||
- mvn clean package -DskipTests
|
||
volumes:
|
||
- /tmp/maven-cache:/root/.m2
|
||
when:
|
||
event: [push, pull_request]
|
||
branch: master
|
||
|
||
- name: 官方标准构建与推送 (宿主机物理硬缓存版)
|
||
image: woodpeckerci/plugin-docker-buildx:latest-insecure
|
||
privileged: true
|
||
# 💡 核心外挂 1:把宿主机的 docker.sock 和 buildx 缓存目录直接挂载进来!
|
||
# 这样插件在执行命令时,直接吃的是你服务器本地已经下载好的镜像,绝不联网,0秒结束
|
||
volumes:
|
||
- /var/run/docker.sock:/var/run/docker.sock
|
||
- /var/lib/docker:/var/lib/docker
|
||
- /root/.docker:/root/.docker
|
||
settings:
|
||
repo: push.lovestory.cyou/abhors/demo
|
||
registry: push.lovestory.cyou
|
||
insecure: true
|
||
username:
|
||
from_secret: nexus_docker_username
|
||
password:
|
||
from_secret: nexus_docker_password
|
||
output: type=image,push=true
|
||
|
||
# 内部编译器只认你的内网私服,彻底断绝外网
|
||
buildkit_config: |
|
||
[registry."docker.io"]
|
||
mirrors = ["registry.lovestory.cyou"]
|
||
[registry."push.lovestory.cyou"]
|
||
http = true
|
||
insecure = true
|
||
[registry."registry.lovestory.cyou"]
|
||
http = true
|
||
insecure = true
|
||
when:
|
||
event: push
|
||
branch: master
|
||
|
||
- name: 远程终端部署
|
||
image: push.lovestory.cyou/appleboy/drone-ssh:latest
|
||
settings:
|
||
host: *DEPLOY_HOST
|
||
port: *DEPLOY_PORT
|
||
username:
|
||
from_secret: *DEPLOY_USER_SECRET
|
||
password:
|
||
from_secret: *DEPLOY_PASS_SECRET
|
||
secrets: [ nexus_docker_username, nexus_docker_password ]
|
||
envs: [ nexus_docker_username, nexus_docker_password ]
|
||
script:
|
||
- echo "========================================="
|
||
- echo "🚀 开始部署节点:*DEPLOY_HOST"
|
||
- echo "========================================="
|
||
- docker login --username "$nexus_docker_username" --password "$nexus_docker_password" "push.lovestory.cyou"
|
||
- docker stop "demo-container" || true
|
||
- docker rm "demo-container" || true
|
||
- docker pull "push.lovestory.cyou/abhors/demo:latest"
|
||
- docker run -d --name "demo-container" -p 8080:8080 --restart always "push.lovestory.cyou/abhors/demo:latest"
|
||
when:
|
||
event: push
|
||
branch: master |