韩皓
2021-06-29 11:09
浏览 8

docker设置volumes将yarn的全局缓存保存到数据卷中问题

gitlab-runner中使用docker模式,设置volumes将yarn的全局缓存保存到数据卷中问题

### 问题描述
在设置gitlab-runner中模式选为docker

### 问题出现的平台版本

```
yarn -v
v1.22.5
```

```
node -v
v16.3.0
```

```
docker -v
Docker version 20.10.7, build f0df350
```

```
gitlab-runner -v

Version:      13.12.0
Git revision: 7a6612da
Git branch:   13-12-stable
GO version:   go1.16.3
Built:        2021-05-20T23:59:54+01:00
OS/Arch:      darwin/amd64
```

### 相关代码
这个是我的gitlab-runner config
/usr/local/share/.cache/为镜像中yarn的全局缓存目录
```
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "xxxx"
  url = "http://xxxxx"
  token = "xxxxxx"
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
  [runners.docker]
    tls_verify = false
    image = "node"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/Users/xxxx/home/cache:/usr/local/share/.cache/"]   

```
这个是我.gitlab-ci.yml文件

```
image: node

stages:
  - build

variables:
  GIT_STRATEGY: clone

build:
  stage: build
  image: node
  script: 
    - yarn install
  only:
    - feature/1.0.0
  tags:
    - fe
  timeout: 10m


```


### 你期待的结果是什么?实际看到的错误信息又是什么?
在ci执行到script时,yarn会显示网络错误,我确保我挂靠到volumes的文件权限为777
```
$ yarn install --har
yarn install v1.22.5
[1/5] Resolving packages...
[2/5] Fetching packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
```
我期待得到的结果是我的依赖安装完成。

相关推荐 更多相似问题