This commit is contained in:
parent
432cf4e768
commit
63717f5327
188
.drone.yml
188
.drone.yml
@ -1,24 +1,49 @@
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
#设置挂载
|
||||
volumes:
|
||||
#Go编译缓存
|
||||
- name: pkgdeps
|
||||
host:
|
||||
path: /mnt/drone/cache/go
|
||||
#Docker环境
|
||||
- name: docker
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
#Docker配置
|
||||
- name: docker-daemon
|
||||
host:
|
||||
path: /etc/docker/daemon.conf
|
||||
|
||||
clone:
|
||||
disable: false # 启用代码拉取
|
||||
|
||||
steps:
|
||||
# 开发版
|
||||
- name: docker-${DRONE_BRANCH}
|
||||
image: plugins/docker
|
||||
settings:
|
||||
username: liupeng
|
||||
password:
|
||||
from_secret: DOCKER_PASSWORD
|
||||
registry: git.daymele.com
|
||||
repo: git.daymele.com/liupeng/drone
|
||||
insecure: true
|
||||
debug: true
|
||||
dockerfile: Dockerfile
|
||||
tags:
|
||||
- canary
|
||||
#设置缓存
|
||||
- name: clean
|
||||
image: docker
|
||||
network_mode: host
|
||||
# 将宿主机的 docker和配置挂载到运行的 docker 容器中,那么在容器中运行 docker 命令时,等同于在宿主机中运行该docker 命令
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- name: images
|
||||
path: /images
|
||||
- name: docker-daemon
|
||||
path: /etc/docker/daemon.conf
|
||||
|
||||
#构建镜像
|
||||
- name: build
|
||||
image: golang:latest
|
||||
pull: if-not-exists
|
||||
volumes:
|
||||
- name: pkgdeps
|
||||
path: /go/pkg
|
||||
environment:
|
||||
GOPROXY: "https://goproxy.cn,direct" # 懂的都懂
|
||||
commands:
|
||||
- CGO_ENABLED=0 go build -o adapt -ldflags="-w -s"
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
@ -26,23 +51,82 @@ steps:
|
||||
event:
|
||||
- push
|
||||
|
||||
# 稳定版
|
||||
- name: docker-release
|
||||
|
||||
#推送镜像至镜像仓库
|
||||
- name: publish
|
||||
image: plugins/docker
|
||||
pull: if-not-exists
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- name: pkgdeps
|
||||
path: /cache
|
||||
# mirrors: #镜像仓库加速地址,不需要加速,可以直接删除
|
||||
# from_secret: registry_mirrors
|
||||
settings:
|
||||
username: liupeng
|
||||
password:
|
||||
from_secret: DOCKER_PASSWORD
|
||||
registry: git.daymele.com
|
||||
repo: git.daymele.com/liupeng/drone
|
||||
insecure: true
|
||||
dockerfile: Dockerfile
|
||||
purge: false
|
||||
registry: git.daymele.com
|
||||
repo: git.daymele.com/liupeng/drone
|
||||
tags:
|
||||
- ${DRONE_TAG}
|
||||
- latest
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
username: liupeng
|
||||
password: #镜像仓库密码
|
||||
from_secret: DOCKER_PASSWORD
|
||||
|
||||
#部署镜像服务
|
||||
# - name: ssh commands
|
||||
# image: appleboy/drone-ssh
|
||||
# pull: if-not-exists
|
||||
# settings:
|
||||
# host: dev.daymele.com
|
||||
# port: 22
|
||||
# username:
|
||||
# from_secret: liup
|
||||
# key:
|
||||
# from_secret: HOST_KEY
|
||||
# script:
|
||||
# - cd /home/dockerConfig/project/go-gin
|
||||
# - docker-compose pull && docker-compose up --force-recreate -d
|
||||
# - docker rmi $(docker images | grep go-fblsj/person-api | grep none | awk '{print $3}')
|
||||
|
||||
# 开发版
|
||||
# - name: docker-${DRONE_BRANCH}
|
||||
# image: plugins/docker
|
||||
# settings:
|
||||
# username: liupeng
|
||||
# password:
|
||||
# from_secret: DOCKER_PASSWORD
|
||||
# registry: git.daymele.com
|
||||
# repo: git.daymele.com/liupeng/drone
|
||||
# insecure: true
|
||||
# debug: true
|
||||
# dockerfile: Dockerfile
|
||||
# tags:
|
||||
# - canary
|
||||
# when:
|
||||
# branch:
|
||||
# - master
|
||||
# - dev
|
||||
# event:
|
||||
# - push
|
||||
|
||||
# 稳定版
|
||||
# - name: docker-release
|
||||
# image: plugins/docker
|
||||
# settings:
|
||||
# username: liupeng
|
||||
# password:
|
||||
# from_secret: DOCKER_PASSWORD
|
||||
# registry: git.daymele.com
|
||||
# repo: git.daymele.com/liupeng/drone
|
||||
# insecure: true
|
||||
# dockerfile: Dockerfile
|
||||
# tags:
|
||||
# - ${DRONE_TAG}
|
||||
# - latest
|
||||
# when:
|
||||
# event:
|
||||
# - tag
|
||||
|
||||
|
||||
- name: deploy-${DRONE_BRANCH}
|
||||
@ -60,7 +144,7 @@ steps:
|
||||
script:
|
||||
- echo "deploy docker ssh!"
|
||||
- name=drone-test
|
||||
- image=git.daymele.com/liupeng/drone:canary
|
||||
- image=git.daymele.com/liupeng/drone:latest
|
||||
- echo ${DRONE_BRANCH}
|
||||
- docker pull $image
|
||||
- docker rm -f drone-test || true
|
||||
@ -74,26 +158,28 @@ steps:
|
||||
- push
|
||||
|
||||
|
||||
- name: deploy-release
|
||||
image: appleboy/drone-ssh
|
||||
settings:
|
||||
host:
|
||||
- pub.daymele.com
|
||||
username: liup
|
||||
# password:
|
||||
# from_secret: HOST_PASSWORD
|
||||
key:
|
||||
from_secret: HOST_KEY
|
||||
port: 22
|
||||
command_timeout: 2m
|
||||
script:
|
||||
- echo "deploy podman ssh!"
|
||||
- name=drone-release
|
||||
- image=git.daymele.com/liupeng/drone:latest
|
||||
- podman pull $image
|
||||
- podman rm -f drone-release || true
|
||||
- podman image prune -f
|
||||
- podman run --name=$name -d -p 8002:9000 -v /etc/conf:/conf $image
|
||||
when:
|
||||
event:
|
||||
- tag
|
||||
# - name: deploy-release
|
||||
# image: appleboy/drone-ssh
|
||||
# settings:
|
||||
# host:
|
||||
# - pub.daymele.com
|
||||
# username: liup
|
||||
# # password:
|
||||
# # from_secret: HOST_PASSWORD
|
||||
# key:
|
||||
# from_secret: HOST_KEY
|
||||
# port: 22
|
||||
# command_timeout: 2m
|
||||
# script:
|
||||
# - echo "deploy podman ssh!"
|
||||
# - name=drone-release
|
||||
# - image=git.daymele.com/liupeng/drone:latest
|
||||
# - podman pull $image
|
||||
# - podman rm -f drone-release || true
|
||||
# - podman image prune -f
|
||||
# - podman run --name=$name -d -p 8002:9000 -v /etc/conf:/conf $image
|
||||
# when:
|
||||
# event:
|
||||
# - tag
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user