-
Notifications
You must be signed in to change notification settings - Fork 2
/
.drone.docker.yml
31 lines (29 loc) · 1.21 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
kind: pipeline
type: docker #在docker runner中运行
name: CI & CD
steps:
- name: build & deploy #部署到服务器上
image: docker
volumes:
- name: sock
path: /var/run/docker.sock
- name: wechat-mp-server
path: /opt/wechat-mp-server
commands:
- echo ====开始构建容器=======
- docker build -t wechat-mp-server:latest -f Dockerfile .
- echo ====开始停止容器=======
- if docker ps -a| grep -q "wechat-mp-server";then docker stop `docker ps -a| grep wechat-mp-server | awk '{print $1}'`;fi
- if docker ps -a| grep -q "wechat-mp-server";then docker rm -f `docker ps -a| grep wechat-mp-server | awk '{print $1}'`;fi
- echo ====开始启动容器=======
- docker run --name wechat-mp-server --restart=always -v /opt/wechat-mp-server/logs:/root/logs -v /opt/wechat-mp-server/application.yaml:/root/application.yaml --publish 127.0.0.1:10151:10151 -d wechat-mp-server:latest
- echo ====部署成功======
- docker image prune -a -f # 清理无用镜像
# 挂载宿主机文件到docker容器中
volumes:
- name: sock
host:
path: /var/run/docker.sock
- name: wechat-mp-server
host:
path: /opt/wechat-mp-server