[英]Gitlab CI with Docker and NPM
I'm trying to setup a basic pipeline in Gitlab that does the following: Run tests command, compile the client and deploy the application using docker-compose. 我正在尝试在Gitlab中设置执行以下操作的基本管道:运行tests命令,编译客户端,然后使用docker-compose部署应用程序。
The problem comes when I'm trying to use npm install
. 当我尝试使用npm install
时,问题就来了。
My .gitlab-ci.yml
file looks like: 我的.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
And the error is: 错误是:
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
I'm using the last docker image, so, I'm wondering whether I can define a new service on my build stage or should I use a different image for the whole process? 我正在使用最后一个docker映像,所以我想知道是否可以在构建阶段定义新服务,还是在整个过程中使用不同的映像?
Thanks 谢谢
A new service will not help you , you'll need to use a different image. 一项新服务将无济于事 ,您需要使用其他图像。 You can use a node image just for your build
-stage like this: 您可以将节点映像仅用于build
阶段,如下所示:
build: image: node:8 stage: build script: - cd packages/public/client/ - npm install --only=production - npm run build
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.