-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.drone-docker.yml
119 lines (110 loc) · 2.74 KB
/
.drone-docker.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
kind: pipeline
name: demo
trigger:
branch:
include:
- feature/*
- master
- dev
event:
include:
- push
- pull_request
steps:
- name: restore-cache
image: drillster/drone-volume-cache
volumes:
- name: cache
path: /cache
settings:
restore: true
mount:
- ./vendor
# - name: build
# image: golang:1.13
# commands:
# - make build
- name: publish
image: plugins/docker
when:
branch:
- master
settings:
tags: latest
purge: false
debug: true
mirror: https://registry.docker-cn.com
target: production
repo: gelove/demo
# dockerfile: Dockerfile # dockerfile to be used, defaults to Dockerfile
username:
from_secret: docker_username
password:
from_secret: docker_password
- name: deploy
image: appleboy/drone-ssh
environment:
DOCKER_USERNAME:
from_secret: docker_username
DOCKER_PASSWORD:
from_secret: docker_password
settings:
host:
from_secret: ssh_host
port: 22
command_timeout: 10m
username:
from_secret: ssh_username
password:
from_secret: ssh_password
envs: [DOCKER_USERNAME, DOCKER_PASSWORD]
script:
- mkdir -p /opt/go-docker/demo
- cd /opt/go-docker/demo
- docker ps -a |grep demo |grep -v grep
# 判断 demo 容器是否存在
- \[ $? -eq 0 \] && docker stop demo && docker rm demo
- docker images -a |grep demo |grep -v grep
- \[ $? -eq 0 \] && docker rmi -f gelove/demo
- echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
- docker pull gelove/demo
- docker run -d --name demo -p 9090:9090 gelove/demo
- docker logout
# rollback-online:
# image: docker-registry-cn.easemob.com/kubernetes/im/webim-rollback:latest
# pull: true
# environment:
# - DOCKER_LAUNCH_DEBUG=true
# secrets: [ ssh_key, jumpserver_host, jumpserver_port, online_host ]
# debug: true
# when:
# branch: rollback
- name: restore-cache
image: drillster/drone-volume-cache
volumes:
- name: cache
path: /cache
settings:
rebuild: true
mount:
- ./vendor
- name: notify
image: drillster/drone-email
host: smtp.163.com
username:
from_secret: email_username
password:
from_secret: email_password
from:
from_secret: email_username
recipients: [ 61114099@qq.com, gelove@live.cn ]
# recipients:
# - 61114099@qq.com
# - gelove@live.cn
recipients_only: true
when:
status: [ failure, success ]
volumes:
- name: cache
host:
path: /var/lib/cache