demo/.woodpecker.yaml

87 lines
3.1 KiB
YAML
Raw 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.

# 第 73 次部署
# 💡 全局变量块
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: 镜像构建与推送
# 👇 1. 核心:必须换成官方文档指定的 -insecure 后缀镜像
image: woodpeckerci/plugin-docker-buildx:latest-insecure
privileged: true
settings:
repo: push.lovestory.cyou/abhors/demo
insecure: true # 这个是给内部 dockerd 用的
registry: push.lovestory.cyou
username:
from_secret: nexus_docker_username
password:
from_secret: nexus_docker_password
# 👇 核心修改 2显式指定构建输出模式为常规 image 模式并直接 push
# 强行把 Buildx 启动时要拉取的镜像,换成你自己的私有仓库(或者是你配置过镜像加速能拉到的地方)
buildkit_driveropt: image=push.lovestory.cyou/moby/buildkit:buildx-stable-1
# 这样可以强行阻止 Buildx 启动独立的隔离容器,从而彻底不走官方下载 moby/buildkit 的代码链
output: type=image,push=true
# 👇 2. 核心:完全对齐官方不安全设置文档,强制 BuildKit 放行纯 HTTP
buildkit_config: |
[registry."push.lovestory.cyou"]
http = true
insecure = true
config: |
{
"registry-mirrors": [
"https://docker.1ms.run",
"https://dockerpull.org",
"https://1ms.run",
"https://docker.1panel.dev/"
],
"insecure-registries": [
"registry.lovestory.cyou",
"push.lovestory.cyou"
]
}
when:
event: push
branch: master
- name: 远程终端部署
image: registry.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