forked from open-v2x/edgeview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.drone.yml
72 lines (68 loc) · 2.75 KB
/
.drone.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
kind: pipeline
type: exec
name: push-build
clone:
depth: 5
platform:
os: linux
arch: amd64
node:
node: ci-buildx-2
steps:
- name: build-image
environment:
DOCKER_USER:
from_secret: DOCKER_USERNAME
DOCKER_PASS:
from_secret: DOCKER_PASSWORD
DOCKER_REGISTRY: docker.io
DOCKER_ORG: openv2x
DOCKER_TAG: latest
commands:
- env
- mkdir -pv $HOMEPATH/.docker/buildx/instances
- cp /root/.docker/buildx/instances/cicd $HOMEPATH/.docker/buildx/instances/cicd
- docker buildx ls
- docker buildx use cicd
- echo -n $DOCKER_PASS | docker login $DOCKER_REGISTRY --username $DOCKER_USER --password-stdin
- docker buildx build -f Dockerfile --build-arg BRANCH=${DRONE_BRANCH} --build-arg REPO_URL=${DRONE_REPO} --build-arg COMMIT_REF=${DRONE_COMMIT_SHA} -t $DOCKER_REGISTRY/$DOCKER_ORG/edgeview:$DOCKER_TAG --tag $DOCKER_REGISTRY/$DOCKER_ORG/edgeview:$DOCKER_TAG-${DRONE_COMMIT_SHA:0:6} --platform=linux/arm64,linux/amd64 . --push
- name: clean
environment:
DOCKER_REGISTRY: docker.io
commands:
- docker logout $DOCKER_REGISTRY || true
when:
status:
- success
- failure
- name: predeploy
commands:
- cp -rf /root/.ssh ~/
- name: deploy-to-aliyun
commands:
- ssh v2x-release "rm -rf /etc/edgeview || true"
- ssh v2x-release "mkdir -pv /etc/edgeview"
- ssh v2x-release "docker stop edgeview || true"
- ssh v2x-release "docker rm edgeview || true"
- ssh v2x-release "docker rmi openv2x/edgeview:latest || true"
- ssh v2x-release "docker pull openv2x/edgeview:latest"
- scp deploy/nginx.conf v2x-release:/etc/edgeview/
- scp deploy/edgeview.conf v2x-release:/etc/edgeview/
- ssh v2x-release "docker run -d --name="edgeview" --net=host -e API_SERVER=http://139.196.13.9/api -e MAP_KEY=a7a90e05a37d3f6bf76d4a9032fc9129 -v /etc/localtime:/etc/localtime -v /etc/edgeview/nginx.conf:/etc/nginx/nginx.conf -v /etc/edgeview/edgeview.conf:/etc/nginx/conf.d/default.conf -v /data/public/uploadData:/var/www/edgeview/uploadData openv2x/edgeview:latest || true"
- name: email on success
commands:
- bash -x v2x-email-success.sh ${DRONE_COMMIT} ${DRONE_COMMIT_BRANCH} "${DRONE_COMMIT_AUTHOR_NAME}" ${DRONE_REPO_OWNER} ${DRONE_REPO_NAME} ${DRONE_COMMIT_AUTHOR_EMAIL} ${DRONE_BUILD_NUMBER} ${DRONE_BUILD_STARTED}
when:
status:
- success
- name: email on failure
commands:
- bash -x v2x-email-failure.sh ${DRONE_COMMIT} ${DRONE_COMMIT_BRANCH} "${DRONE_COMMIT_AUTHOR_NAME}" ${DRONE_REPO_OWNER} ${DRONE_REPO_NAME} ${DRONE_COMMIT_AUTHOR_EMAIL} ${DRONE_BUILD_NUMBER} ${DRONE_BUILD_STARTED}
when:
status:
- failure
trigger:
event:
- push
branch:
- master