在 gitlab-runner 中进行 electron 应用打包时发生 RequestError: socket hang up

2022-02-25 17:20:20 +08:00
 gadfly3173

docker 部署的 gitlab/gitlab-ce:14.8.1-ce.0 、gitlab/gitlab-runner:ubuntu-v14.8.0 ,docker-compose.yml 如下

 version: '2'
 services:
     gitlab:
       image: 'gitlab/gitlab-ce:14.8.1-ce.0'
       container_name: "gitlab"
       restart: unless-stopped
       hostname: 'docker-gitlab-01'
       environment:
         TZ: 'Asia/Shanghai'
         # 这里的配置其实就是 /etc/gitlab/gitlab.rb 中的配置,按自己的实际需求增减
         GITLAB_OMNIBUS_CONFIG: |
           external_url 'xxx'
           gitlab_rails['time_zone'] = 'Asia/Shanghai'
           prometheus['enable'] = false
           gitlab_rails['gitlab_shell_ssh_port'] = xxx
           nginx['listen_port'] = 80
           nginx['listen_https'] = false
       ports:
         - 'xxx:80'
         - 'xxx:22'
       volumes:
         - /opt/gitlab/config:/etc/gitlab
         - /opt/gitlab/data:/var/opt/gitlab
         - /opt/gitlab/logs:/var/log/gitlab
       networks:
         - gitlab
 
     gitlab-runner:
       image: gitlab/gitlab-runner:ubuntu-v14.8.0
       container_name: "gitlab-runner"
       restart: unless-stopped
       depends_on:
         - gitlab
       volumes:
         - ./opt/gitlab-runner:/etc/gitlab-runner
         - /var/run/docker.sock:/var/run/docker.sock
         - ./gitlab-runner:/home/gitlab-runner
       networks:
         - gitlab
 
 networks:
     gitlab:

目录挂载网上抄的,有点乱。gitlab-runner 为 docker 模式,gitlab-ci.yml 如下:

stages:
  - build

build:
  # image: electronuserland/builder:14-wine-01.22
  image: node:16.14.0-alpine3.14
  stage: build
  script:
    - node -v
    - npm -v
    - yarn
    - yarn electron:build
  artifacts:
    expire_in: 30 days
    paths:
      - ./dist_electron/
  only:
    - release
  tags:
    - default

现在在执行 yarn ,进入 [4/4] Building fresh packages... 后,就会弹出如下失败日志:

[4/4] Building fresh packages...
error /builds/xxxxxx/node_modules/electron: Command failed.
Exit code: 1
Command: node install.js
Arguments: 
Directory: /builds/xxxxxxxxxx/node_modules/electron
Output:
RequestError: socket hang up
    at ClientRequest.<anonymous> (/builds/xxxxxxx/node_modules/got/source/request-as-event-emitter.js:178:14)
    at Object.onceWrapper (node:events:640:26)
    at ClientRequest.emit (node:events:532:35)
    at ClientRequest.origin.emit (/builds/xxxxxxxxx/node_modules/@szmarczak/http-timer/source/index.js:37:11)
    at TLSSocket.socketOnEnd (node:_http_client:466:9)
    at TLSSocket.emit (node:events:532:35)
    at endReadableNT (node:internal/streams/readable:1346:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
ERROR: Job failed: exit code 1

项目使用@vue/cli@5.0.1vue-cli-plugin-electron-builder@3.0.0-alpha.4electron@17.1.0构建 尝试在 gitlab-runner 的 docker 中和服务器上直接执行都没有失败,求大佬们看看可以怎么排查问题。

1523 次点击
所在节点    GitLab
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/836438

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX