持续部署平台搭建
Posted meilong
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了持续部署平台搭建相关的知识,希望对你有一定的参考价值。
https://gogs.io/
https://drone.io/
https://goharbor.io/
gogs+drone+harbor方式构建,不哆嗦直接上
安装docker
curl -sSL https://get.daocloud.io/docker | sh
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
curl -L https://github.com/docker/compose/releases/download/1.23.0-rc3/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
卸载docker
# 卸载Docker CE
#sudo apt-get purge docker-ce
# 卸载Docker EE
#sudo apt-get purge docker-ee
# 删除Docker镜像、容器、数据卷等文件
#sudo rm -rf /var/lib/docker
部署平台
version: '3'
services:
db:
image: postgres:10
hostname: gogs
hostname: gogs-db
container_name: gogs-db
restart: always
environment:
POSTGRES_PASSWORD: postgres
volumes:
- ./gogsdb:/var/lib/postgresql/data
ports:
- "5432:5432"
networks:
cinet:
ipv4_address: '172.72.72.72'
gogs:
image: gogs/gogs
hostname: gogs
container_name: gogs
restart: always
volumes:
- ./gogs:/data
ports:
- "8022:22"
- "3000:3000"
networks:
cinet:
ipv4_address: '172.72.72.69'
depends_on:
- db
drone-server:
image: drone/drone:1.3.1
hostname: drone
container_name: drone
restart: always
ports:
- "9000:80"
networks:
cinet:
ipv4_address: '172.72.72.96'
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DRONE_RUNNER_CAPACITY=2
- DRONE_DEBUG=true
- DRONE_OPEN= false
- DRONE_LOGS_TRACE=true
- DRONE_TLS_AUTOCERT=false
- DRONE_AGENTS_ENABLED=true
- DRONE_GIT_ALWAYS_AUTH=false
- DRONE_GOGS_SERVER=http://172.72.72.69:3000
- DRONE_RPC_SECRET=123456
- DRONE_SERVER_PROTO=http
- DRONE_SERVER_HOST=172.72.72.96
- DRONE_DATABASE_DRIVER=postgres
- DRONE_DATABASE_DATASOURCE=postgres://drone:password@172.72.72.72:5432/drone?sslmode=disable
drone-agent:
image: drone/agent:latest
hostname: drone-agent
container_name: drone-agent
restart: always
networks:
cinet:
ipv4_address: '172.72.72.99'
environment:
- DRONE_DEBUG=true
- DRONE_RPC_PROTO=http
- DRONE_RPC_SERVER=http://172.72.72.96:80
- DRONE_RPC_SECRET=123456
- DRONE_RUNNER_CAPACITY=2
- DRONE_RUNNER_NAME=agent
volumes:
- /etc/localtime:/etc/localtime
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- drone-server
networks:
cinet:
ipam:
driver: default
config:
- subnet: 172.72.72.0/16
Pipeline
---
kind: pipeline
type: docker
name: build
clone:
git clone:
image: plugins/git
skip_verify: true
workspace:
base: /app
path: .
pipeline:
build& push:
image: plugins/docker
username: username
password:
from_secret: password
debug: true
build_args:
- ENV=prod
tag:
- $CI_COMMIT_SHA:0:10
insecure: true
dockerfile: cicd/Dockerfile
registry: harbor-repo-url
repo: image-url
when:
branch: master
event: [push,tag]
pipeline:
notification:
image: guoxudongdocker/drone-dingtalk
token:
from_secret: password
type: markdown
message_color: true
message_pic: true
sha_link: true
when:
status: [success, failure]
以上是关于持续部署平台搭建的主要内容,如果未能解决你的问题,请参考以下文章
如何搭建自己的CI/CD平台:Gitlab+Jenkins+Docker+Harbor+K8s集群搭建CICD平台(持续集成部署Hexo博客Demo)
Gitlab+Jenkins+Docker+Harbor+K8s集群搭建CICD平台