gitlab.com CI – 在docker中使用docker构build一个NodeJS应用程序

我目前正面临着gitlab.com共享运行者的问题。 我正在努力实现的是:
– NPM安装和使用咕噜做一些uncss,最小化和压缩的任务
– 清理 – build立一个包括应用程序的docker集装箱
– 将容器移动到gitlabregistry

不幸的是我很长一段时间没有运行! 我尝试了很多不同的gitlab.ciconfiguration – 没有成功。 问题是,我必须使用“image:docker:latest”来运行所有docker-tools。 但是,我没有在容器中安装node和grunt。
另一种方式是不工作。 我正在尝试使用image:centos:latest并手动安装docker – 但是这也不能正常工作,因为我总是得到一个Failed to get D-Bus connection: Operation not permitted
有没有人有更多的经验,在docker共享运行使用dockerbuild设命令的gitlab-ci?
任何帮助,高度赞赏!

谢谢
Jannik

Gitlab可能有点棘手:)我没有一个基于CentOS的例子,但我有一个基于Ubuntu的,如果这可以帮助你。 这里是我的一个工作的gitlabpipe道的复制粘贴,它使用了一些gulp(你应该可以很容易地将它调整到适合你的grunt)。

.gitlab-ci.yml看起来像这样(在开始时调整CONTAINER …variables):

 variables: CONTAINER_TEST_IMAGE: registry.gitlab.com/psono/psono-client:$CI_BUILD_REF_NAME CONTAINER_RELEASE_IMAGE: registry.gitlab.com/psono/psono-client:latest stages: - build docker-image: stage: build image: ubuntu:16.04 services: - docker:dind variables: DOCKER_HOST: 'tcp://docker:2375' script: - sh ./var/build-ubuntu.sh - docker info - docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" registry.gitlab.com - docker build -t $CONTAINER_TEST_IMAGE . - docker push $CONTAINER_TEST_IMAGE 

另外我有一个这样的“./var/build-ubuntu.sh”,你可以根据你的需要调整一下,replace一些ubuntu的依赖或者根据需要切换grup。

 #!/usr/bin/env bash apt-get update && \ apt-get install -y libfontconfig zip nodejs npm git apt-transport-https ca-certificates curl openssl software-properties-common && \ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \ add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" && \ apt-get update && \ apt-get install -y docker-ce && \ ln -s /usr/bin/nodejs /usr/bin/node && \ npm install && \ node --version && \ npm --version 
    Interesting Posts