docker - 带有Docker和NPM的Gitlab CI

标签 docker npm gitlab

我正在尝试在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/

相关文章:

python-3.x - 在Docker中从源代码构建numpy

docker - 不能在 docker 容器中使用 vim、vi、nano、yum

node.js - 如何在 Gitlab 中为 nodejs 应用程序运行测试

gitlab - GitLab 的存储库和用户限制是什么

linux - 如何将我的本地 docker 图像导出到 tar 并在另一台计算机上加载

docker - 如何将私有(private)组织镜像从 docker hub 部署到 kubernetes

maven - Npm package.json继承

angularjs - 解决 Windows 7 中的 npm 启动错误

node.js - Azure Nodejs Web 应用程序在部署中缺少 npm 包

github - 与 Gitlab 集成的 Upsource