【问题标题】:Gitlab CI with Docker and NPM带有 Docker 和 NPM 的 Gitlab CI
【发布时间】:2018-10-16 18:04:13
【问题描述】:

我正在尝试在 Gitlab 中设置一个基本管道,该管道执行以下操作: 运行测试命令,编译客户端并使用 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 映像,所以,我想知道是否可以在构建阶段定义新服务,还是应该在整个过程中使用不同的映像?

谢谢

【问题讨论】:

    标签: docker npm gitlab


    【解决方案1】:

    新服务will not help you,您需要使用不同的图像。 您可以像这样为您的build-stage 使用节点图像:

    build: image: node:8 stage: build script: - cd packages/public/client/ - npm install --only=production - npm run build

    【讨论】:

    • @lucaswerner:如果您对我的回答感到满意,请点击大复选框接受。
    猜你喜欢
    • 1970-01-01
    • 2020-08-12
    • 2017-10-06
    • 2017-05-27
    • 2020-03-09
    • 1970-01-01
    • 1970-01-01
    • 2021-03-20
    • 2020-02-02
    相关资源
    最近更新 更多