我正在尝试在Gitlab中设置执行以下操作的基本管道:
运行tests命令,编译客户端,然后使用docker-compose部署应用程序。
当我尝试使用npm install
时,问题就来了。
我的.gitlab-ci.yml
文件如下所示:
# This file is a template, and might need editing before it works on your
project.
# Official docker image.
image: docker:latest
services:
- docker:dind
stages:
- test
- build
- deploy
build:
stage: build
script:
- cd packages/public/client/
- npm install --only=production
- npm run build
test:
stage: test
only:
- develop
- production
script:
- echo run tests in this section
step-deploy-production:
stage: deploy
only:
- production
script:
- docker-compose up -d --build
environment: production
when: manual
错误是:
Skipping Git submodules setup
$ cd packages/public/client/
$ npm install --only=production
bash: line 69: npm: command not found
ERROR: Job failed: exit status 1
我正在使用最后一个docker镜像,所以我想知道是否可以在构建阶段定义新服务,还是在整个过程中使用不同的镜像?
谢谢
最佳答案
新服务will not help you,您需要使用其他图像。
您可以将节点图像仅用于build
-stage,如下所示:
build:
image: node:8
stage: build
script:
- cd packages/public/client/
- npm install --only=production
- npm run build
关于docker - 带有Docker和NPM的Gitlab CI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52823047/