|
|
@ -9,43 +9,35 @@ volumes: |
|
|
|
path: /usr/local/path/gopath |
|
|
|
|
|
|
|
steps: |
|
|
|
- name: golang-build |
|
|
|
image: golang:1.17-alpine3.15 |
|
|
|
volumes: |
|
|
|
- name: gopath |
|
|
|
path: /go |
|
|
|
commands: |
|
|
|
- export GOPROXY=https://goproxy.cn |
|
|
|
- go mod init test-drone |
|
|
|
- go mod tidy |
|
|
|
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o test-drone |
|
|
|
when: |
|
|
|
target: [ "test","pre" ] |
|
|
|
## 使用参数推送稳定镜像 |
|
|
|
|
|
|
|
- name: docker-build |
|
|
|
image: plugins/docker |
|
|
|
- name: tar-prod-push |
|
|
|
privileged: true |
|
|
|
image: repository.241210.com/repository/base/docker-push:2 |
|
|
|
settings: |
|
|
|
username: tjqmhu |
|
|
|
password: tjqm4912 |
|
|
|
repo: registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone |
|
|
|
dockerfile: Dockerfile |
|
|
|
registry: https://registry.cn-hangzhou.aliyuncs.com |
|
|
|
tags: ${DRONE_BUILD_NUMBER} |
|
|
|
tar: ops-api-${DRONE_BUILD_NUMBER}.tar |
|
|
|
commands: |
|
|
|
- docker pull ${IMAGE} |
|
|
|
- docker save ${IMAGE} >ops-api-${DRONE_BUILD_NUMBER}.tar |
|
|
|
- dpr |
|
|
|
- suffix=$(echo "$IMAGE" | awk -F '/' '{split($NF, a, ":"); print a[2]}') |
|
|
|
- docker images | grep "ops-api" | grep ${suffix} | awk '{print $3}' | xargs docker rmi |
|
|
|
when: |
|
|
|
target: [ "test","pre" ] |
|
|
|
target: [ "hi","prod" ] |
|
|
|
|
|
|
|
- name: deployment-replace-prod |
|
|
|
image: repository.241210.com/repository/base/kubectl:4 |
|
|
|
commands: |
|
|
|
- cd web/ |
|
|
|
- sed -i 's!IMAGE_PATH:IMAGE_TAG!'${IMAGE}'!g' deployment.yaml |
|
|
|
when: |
|
|
|
target: [ "exp","prod" ] |
|
|
|
|
|
|
|
- name: rancher-deploy |
|
|
|
privileged: true |
|
|
|
image: registry.cn-hangzhou.aliyuncs.com/hvp/dpr:74 |
|
|
|
settings: |
|
|
|
tar : test-drone-${DRONE_BUILD_NUMBER}.tar |
|
|
|
- name: deploy-prod |
|
|
|
image: repository.241210.com/repository/base/kubectl:4 |
|
|
|
commands: |
|
|
|
- docker login --username=tjqmhu -p "tjqm4912" registry.cn-hangzhou.aliyuncs.com |
|
|
|
- docker pull registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone:${DRONE_BUILD_NUMBER} |
|
|
|
- docker save registry.cn-hangzhou.aliyuncs.com/huvipg/test-drone:${DRONE_BUILD_NUMBER} >test-drone-${DRONE_BUILD_NUMBER}.tar |
|
|
|
- dpr |
|
|
|
- cd web/ |
|
|
|
- kubectl --kubeconfig /kube/${CI_BUILD_TARGET} apply -f deployment.yaml |
|
|
|
when: |
|
|
|
target: ["pre"] |
|
|
|
target: [ "exp","prod" ] |
|
|
|
|