Gitlab-runner(docker实现)复用镜像及开启debug模式
我们使用docker 执行器时发现每次,构建都会去拉取基础镜像,这样很费时间这种情况,我们可以通过修改,runner的配置实现本地存在镜像时,不再去下载镜像首先找到runner的配置文件[root@origin _data]# docker psCONTAINER IDIMAGECOMMANDCREATEDSTATUSPORTSNAMES
·
我们使用docker 执行器时发现每次,构建都会去拉取基础镜像,这样很费时间
这种情况,我们可以通过修改,runner的配置实现本地存在镜像时,不再去下载镜像
首先找到runner的配置文件
[root@origin _data]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3db1ac8dbf0e b96bd51a5387 "/usr/local/bin/mvn-…" 3 minutes ago Up 3 minutes runner--tnccsb4-project-2-concurrent-0-9fb86bb61ae060b9-build-3
c66580bf739d gitlab/gitlab-runner:alpine-v14.2.0 "/usr/bin/dumb-init …" 4 days ago Up About an hour gitlab-runner
[root@origin _data]# docker inspect c66
在容器详情里面找到对应的目录
"Mounts": [
{
"Type": "volume",
"Name": "docker-compose_gitlab-runner-config",
"Source": "/var/lib/docker/volumes/docker-compose_gitlab-runner-config/_data",
"Destination": "/etc/gitlab-runner",
"Driver": "local",
"Mode": "rw",
"RW": true,
"Propagation": ""
},
去到这个目录
[root@origin _data]# cd /var/lib/docker/volumes/docker-compose_gitlab-runner-config/_data
[root@origin _data]# ll
total 4
drwx------. 2 root root 6 Aug 23 13:07 certs
-rw-------. 1 root root 563 Sep 9 00:21 config.toml
[root@origin _data]#
就是这个 config.toml,打开
[root@origin _data]# vim config.toml
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "docker-runner"
url = "http://gitlab.kalpana.top:9080/"
token = "-tNcCsB4AKyK-W6juJS8"
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "alpine:latest"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
加上
pull_policy="if-not-present"
再次执行流水线任务,可以看到已经没有去下载镜像了
开启Debug模式
- 暴露runner端口 8093
version: '3.8'
services:
gitlab-runner:
image: gitlab/gitlab-runner:v14.1.0
container_name: gitlab-runner
restart: always
ports:
- '8093:8093'
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
- 'gitlab-runner-config:/etc/gitlab-runner'
volumes:
gitlab-runner-config: {}
- 修改配置
[root@origin docker-compose]# cd /var/lib/docker/volumes/docker-compose_gitlab-runner-config/_data
[root@origin _data]# vim config.toml
在session_server 节点下增加listen_address ,advertise_address
[session_server]
session_timeout = 1800
listen_address = "[::]:8093"
advertise_address = "192.168.0.103:8093"
- 重启runner
- 再触发流水线可以看到,已经有Debug入口了,在任务执行期间,可以通过这里进入当前runner内部,查看任务具体详情
更多推荐
已为社区贡献3条内容
所有评论(0)