|
|
@@ -0,0 +1,41 @@
|
|
|
+kind: pipeline
|
|
|
+type: docker
|
|
|
+name: default
|
|
|
+
|
|
|
+steps:
|
|
|
+ # 步骤 1: Maven 构建
|
|
|
+ - name: build-with-maven
|
|
|
+ image: maven:3.8.6-openjdk-11-slim
|
|
|
+ commands:
|
|
|
+ - mvn clean package -DskipTests
|
|
|
+
|
|
|
+ # 步骤 2: 构建 Docker 镜像并上传
|
|
|
+ - name: build-and-push-docker-image
|
|
|
+ image: plugins/docker
|
|
|
+ settings:
|
|
|
+ username:
|
|
|
+ from_secret: leonezhurui
|
|
|
+ password:
|
|
|
+ from_secret: 4sKH39!!ut7LRz
|
|
|
+ repo: registry.cn-hangzhou.aliyuncs.com/english-ai/eai-backend
|
|
|
+ tags: latest
|
|
|
+ dockerfile: Dockerfile
|
|
|
+
|
|
|
+ # 步骤 3: 调用脚本进行部署
|
|
|
+ - name: deploy-with-script
|
|
|
+ image: alpine/git # 使用包含 git 的镜像来确保可以执行脚本
|
|
|
+ commands:
|
|
|
+ - chmod +x ./deploy.sh # 确保脚本具有执行权限
|
|
|
+ - ./deploy.sh # 执行脚本
|
|
|
+ environment:
|
|
|
+ IMAGE_TAG: registry.cn-hangzhou.aliyuncs.com/english-ai/eai-backend:latest
|
|
|
+ volumes:
|
|
|
+ - name: docker_socket
|
|
|
+ path: /var/run/docker.sock
|
|
|
+
|
|
|
+
|
|
|
+# 为了让 Drone 能够执行 Docker 命令,需要挂载 Docker 守护进程的 socket
|
|
|
+volumes:
|
|
|
+ - name: docker_socket
|
|
|
+ host:
|
|
|
+ path: /var/run/docker.sock
|