230 lines
5.0 KiB
Markdown
230 lines
5.0 KiB
Markdown
---
|
||
title: 环境容器
|
||
categories:
|
||
- CS
|
||
status: todo
|
||
abbrlink: 63667
|
||
---
|
||
|
||
# 常用compose
|
||
|
||
```yaml
|
||
version: '3.8'
|
||
services:
|
||
caddy:
|
||
image: caddy:latest
|
||
container_name: caddy
|
||
restart: always
|
||
ports:
|
||
- "80:80"
|
||
- "443:443"
|
||
volumes:
|
||
- /www/wwwroot/caddy/Caddyfile:/etc/caddy/Caddyfile
|
||
- /www/wwwroot/caddy/data:/data
|
||
- /www/wwwroot/caddy/config:/config
|
||
- /www/wwwroot/caddy/html:/usr/share/caddy
|
||
networks:
|
||
- mozzie-net
|
||
|
||
mysql:
|
||
image: mysql:latest
|
||
container_name: mysql
|
||
restart: always
|
||
environment:
|
||
# 改自己的
|
||
MYSQL_ROOT_PASSWORD: xxxxxxx
|
||
TZ: Asia/Shanghai
|
||
volumes:
|
||
- /www/wwwroot/mysql:/var/lib/mysql
|
||
ports:
|
||
- "6033:3306"
|
||
networks:
|
||
- mozzie-net
|
||
|
||
mongo:
|
||
image: mongo:latest
|
||
container_name: mongo
|
||
restart: always
|
||
environment:
|
||
# 改自己的
|
||
MONGO_INITDB_ROOT_USERNAME: xxxxxxx
|
||
# 改自己的
|
||
MONGO_INITDB_ROOT_PASSWORD: xxxxxxx
|
||
ports:
|
||
- "37017:27017"
|
||
volumes:
|
||
- /www/wwwroot/mongodb:/data/db
|
||
networks:
|
||
- mozzie-net
|
||
|
||
gitea:
|
||
image: gitea/gitea:latest
|
||
container_name: gitea
|
||
restart: always
|
||
environment:
|
||
- TZ=Asia/Shanghai
|
||
ports:
|
||
- "10022:22"
|
||
- "3000:3000"
|
||
volumes:
|
||
- /www/wwwroot/gitea/data:/data
|
||
depends_on:
|
||
- mysql
|
||
networks:
|
||
- mozzie-net
|
||
|
||
drone-server:
|
||
image: drone/drone:latest
|
||
container_name: drone-server
|
||
volumes:
|
||
- /www/wwwroot/drone/:/data/docker/drone
|
||
environment:
|
||
DRONE_AGENTS_ENABLED: 'true'
|
||
DRONE_GIT_ALWAYS_AUTH: 'true'
|
||
DRONE_TLS_AUTOCERT: 'true'
|
||
DRONE_GITEA_SERVER: 'https://git.maxshader.com'
|
||
# 看gitea创建OAuth2应用后提供的ID
|
||
DRONE_GITEA_CLIENT_ID: '6a476381-1618-450b-9492-26e43abbb5d0'
|
||
# 看gitea创建OAuth2应用后提供的ID
|
||
DRONE_GITEA_CLIENT_SECRET: 'gto_c4tu5jovdzvgk3sscjqsya7ecd63vxnwe6c5ysrnx3jobvxzknwq'
|
||
# 随意 openssl rand -hex 16,和下面 drone-runner-docker 要求一一致
|
||
DRONE_RPC_SECRET: '26cdbe261717013601989df793a3cc38'
|
||
DRONE_SERVER_HOST: ci.maxshader.com
|
||
DRONE_SERVER_PROTO: 'https'
|
||
DRONE_USER_CREATE: 'username:mozzie,admin:true'
|
||
ports:
|
||
- "8081:80"
|
||
- "8443:443"
|
||
networks:
|
||
- mozzie-net
|
||
restart: always
|
||
|
||
drone-runner-docker:
|
||
image: drone/drone-runner-docker:latest
|
||
container_name: drone-runner-docker
|
||
volumes:
|
||
- /var/run/docker.sock:/var/run/docker.sock
|
||
environment:
|
||
DRONE_RPC_PROTO: http
|
||
DRONE_RPC_HOST: drone-server
|
||
DRONE_RPC_SECRET: 26cdbe261717013601989df793a3cc38
|
||
DRONE_RUNNER_CAPACITY: 2
|
||
DRONE_RUNNER_NAME: drone-runner-docker
|
||
DRONE_TLS_AUTOCERT: 'true'
|
||
networks:
|
||
- mozzie-net
|
||
restart: always
|
||
|
||
filebrowser:
|
||
image: filebrowser/filebrowser
|
||
container_name: filebrowser
|
||
# 直接挂整个wwwroot目录是个人习惯
|
||
volumes:
|
||
- /www/wwwroot/:/srv
|
||
restart: always
|
||
networks:
|
||
- mozzie-net
|
||
|
||
navidrome:
|
||
image: deluan/navidrome:latest
|
||
container_name: navidrome
|
||
ports:
|
||
- "4533:4533"
|
||
restart: unless-stopped
|
||
volumes:
|
||
- "/www/wwwroot/navidrome/data:/data"
|
||
- "/www/wwwroot/navidrome/music:/music:ro"
|
||
networks:
|
||
- mozzie-net
|
||
|
||
it-tools:
|
||
image: corentinth/it-tools:latest
|
||
container_name: it-tools
|
||
ports:
|
||
- "22312:80"
|
||
restart: unless-stopped
|
||
networks:
|
||
- mozzie-net
|
||
|
||
networks:
|
||
mozzie-net:
|
||
name: mozzie-net
|
||
driver: bridge
|
||
|
||
```
|
||
|
||
对应 caddy 配置,也就是上面挂载的 `Caddyfile`
|
||
|
||
```conf
|
||
maxshader.com {
|
||
root * /usr/share/caddy/
|
||
file_server
|
||
encode gzip
|
||
}
|
||
|
||
www.maxshader.com {
|
||
redir https://maxshader.com{uri}
|
||
}
|
||
|
||
git.maxshader.com {
|
||
reverse_proxy gitea:3000
|
||
}
|
||
|
||
music.maxshader.com {
|
||
reverse_proxy navidrome:4533
|
||
}
|
||
|
||
file.maxshader.com {
|
||
reverse_proxy filebrowser
|
||
}
|
||
|
||
ci.maxshader.com {
|
||
reverse_proxy drone-server
|
||
}
|
||
|
||
it.maxshader.com {
|
||
reverse_proxy it-tools
|
||
}
|
||
```
|
||
|
||
# drone ci卡pending
|
||
|
||
[done-runner-exec 官方安装文档](https://docs.drone.io/runner/exec/installation/linux/)
|
||
|
||
```bash
|
||
# 1.拉不下来就手动下载,再传到服务器解压
|
||
curl -L https://github.com/drone-runners/drone-runner-exec/releases/latest/download/drone_runner_exec_linux_amd64.tar.gz | tar zx
|
||
|
||
# 2.解压 移动到 /usr/local/bin
|
||
tar -zxvf drone_runner_exec_linux_amd64.tar.gz
|
||
mv ./drone-runner-exec /usr/local/bin
|
||
|
||
# 3.添加/修改 配置
|
||
mkdir /etc/drone-runner-exec
|
||
vim /etc/drone-runner-exec/config
|
||
```
|
||
|
||
写入内容
|
||
|
||
```bash
|
||
# http协议
|
||
DRONE_RPC_PROTO=https
|
||
# drone web服务地址
|
||
DRONE_RPC_HOST=ci.maxshader.com
|
||
# drone 安装 rpc key,和上面一致
|
||
DRONE_RPC_SECRET=26cdbe261717013601989df793a3cc38
|
||
```
|
||
|
||
安装 drone-runner-exec, 注册系统 service
|
||
|
||
```bash
|
||
# 配置完成后,运行 drone-runner-exec 注册系统service
|
||
drone-runner-exec service install
|
||
drone-runner-exec service start
|
||
drone-runner-exec service stop
|
||
|
||
# 查看服务状态
|
||
systemctl status drone-runner-exec
|
||
# 取消开机自动启动
|
||
systemctl disable drone-runner-exec
|
||
``` |