场景是这样,在 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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…