Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.2k views
in Technique[技术] by (71.8m points)

关于 gitlab-runner 中 node 环境的问题

场景是这样,在 docker 中运行 gitlab-runner,docker-compose 文件如下。

version: "3"
services:
  app:
    image: gitlab/gitlab-runner
    container_name: gitlab-runner-docker
    restart: always
    volumes:
      - ./config:/etc/gitlab-runner
      - /home/wjw/www/srv/gitlab-runner/docker.sock:/var/run/docker.sock
      - /usr/bin/docker:/usr/bin/docker:

现在有一个问题,运行 ci 脚本的时候,runner 容器中没有 npm 的环境,所以执行打包命令会报错。请问这个该怎么解决?

测试文件:

stages:
  - deploy
  - rollback

cache:
  paths:
    - node_modules/

# dev
deploy_develop:
  stage: deploy
  only:
    - dev
  tags:
    - blog
  script:
    - echo $HOME
    - ls -al
    - who
    - npm i


# 部署 production 环境
deploy_production:
  stage: deploy
  only:
    - master
  tags:
    - blog
  script:
    - echo $HOME
  when: manual


# 线上回滚
deploy_production_rollback:
  stage: rollback 
  only:
    - master
  tags:
    - social-h5
  script:
    - echo $HOME
  when: manual

image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...