使用docker-compose搭建drone服务器
1. docker-compose介绍
docker-compose文档:https://docs.docker.com/compose/
drone文档:https://docs.drone.io/
2. 安装docker-compose
yum -y install epel-release
yum -y install python-pip
pip install --upgrade pip
pip install docker-compose
#安装补全工具
yum install bash-completion
curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose
3. 建立工作路径
mkdir docker-workspace
cd docker-workspace
4. 创建docker-compose.yaml
version: '2'
services:
#gogs:
#image: gogs/gogs:latest
#ports:
# - "10022:22"
# - 3000:3000
#volumes:
# - /vagrant/gogs-data:/data
#restart: always
#mysql:
#image: mysql:latest
#ports:
# - 3306:3306
#volumes:
# - /vagrant/mysql-data:/var/lib/mysql
#restart: always
#environment:
# - MYSQL_ROOT_PASSWORD=baicells
# - MYSQL_DATABASE=gogs
drone-server:
image: drone/drone:latest
ports:
- 8000:8000
- 9000:9000
volumes:
- /var/lib/drone:/var/lib/drone
restart: always
environment:
# 开启注册,此配置允许任何人自注册和登录系统
- DRONE_OPEN=true
#直接配置172.17.32.212:9000 会报错
- DRONE_HOST=http://192.168.9.105:9000
# 设置管理员用户
- DRONE_ADMIN=dongfeng
# 开启Gogs驱动
- DRONE_GOGS=true
# Gogs服务器地址
- DRONE_GOGS_URL=http://192.168.9.105:60080
# 此SECRET为任意值
- DRONE_SECRET=YeNmPSFyl090RMy4
drone-agent:
image: drone/agent:latest
command: agent
restart: always
depends_on:
- drone-server
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
# Drone Server 地址,无需加http://
- DRONE_SERVER=192.168.9.105:9000
# 与Drone Server一致即可
- DRONE_SECRET=YeNmPSFyl090RMy4
5. 启动应用
docker-compose up -d
6. 访问
http://192.168.9.105:8000