K8s 实战(4) - CentOS Docker 生产环境部署 Registry, RegistryUI, Gitea, GitWebHook 服务

Compose 安装 Gitea

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
version: "3.7"

networks:
gitea:
external: false

services:
gitea:
image: gitea/gitea:latest
restart: always
environment:
- USER_UID=1000
- USER_GID=1000
ports:
- "10022:22"
- "10080:3000"
volumes:
- ./gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
networks:
- gitea

PS: 主要问题在于配置 git 的访问地址(需要修改配置文件).

Compose 安装 Registry, RegistryUI

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
32
33
34
35
36
37
38
39
40
version: "3.7"

services:
docker-hub:
image: registry:2
restart: always
ports:
- 5000:5000
environment:
REGISTRY_HTTP_TLS_CERTIFICATE: /certs/xxx.pem
REGISTRY_HTTP_TLS_KEY: /certs/xxx.key
# REGISTRY_HTTP_SECRET: xxx
# REGISTRY_HTTP_ADDR: 0.0.0.0:443
REGISTRY_AUTH: htpasswd
REGISTRY_AUTH_HTPASSWD_REALM: "Registry Realm"
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
volumes:
- ./auth:/auth
- ./certs:/certs
- ./conf:/etc/docker/registry
- ./registry-data:/var/lib/registry
networks:
- registry-ui-net

docker-ui:
image: joxit/docker-registry-ui:latest
restart: always
ports:
- 18080:80
environment:
DELETE_IMAGES: 1
#URL: http://docker-hub:5000
REGISTRY_TITLE: "Docker Registry"
REGISTRY_URL: https://docker-hub:5000
#REGISTRY_HTTP_HEADERS_Access-Control-Allow-Origin: "*"
networks:
- registry-ui-net

networks:
registry-ui-net:

细节和注意的问题, 参考另一篇文字: 安装 Docker Registry 和 Registry UI

PS: 主要的细节问题在于 授权, https 证书.

Compose 安装 GitWebHook

其实 Git Web Hook 是自己写的一个 http 服务, 接收 Gitea 的 Web Hook 回调, 然后执行一系列 shell 命令.

这个服务的用意是简易版的 Jenkins.

1
2
3
4
5
6
7
8
9
10
11
12
version: "3.7"

services:
anaconda:
image: "continuumio/anaconda3"
restart: always
volumes:
- .:/data
ports:
- "15000:15000"
working_dir: /data
entrypoint: "./start.sh"

.flashenv

1
2
3
export FLASK_APP=main.py
export FLASK_ENV=development
export FLASK_DEBUG=1

start.sh

1
2
pip install python-dotenv
python -m flask run -h 0.0.0.0 -p 15000

PS: 主要难点在于解析数据结构, 获取项目, 分支, 提交信息, 使用自动化构建.

Donate - Support to make this site better.
捐助 - 支持我让我做得更好.