如何在Gitlab CI中使用Dockerfile

使用gitlab-ci作为我的节点/反应应用程序,我试图使用phusion/passenger-nodejs作为基础泊坞窗

我可以很容易地在.gitlab-ci.yml中指定:

 image: phusion/passenger-nodejs:latest variables: HOME: /root cache: paths: - node_modules/ stages: - build - test - deploy set_environment: stage: build script: - npm install tags: - docker test_node: stage: test script: - npm install - npm test tags: - docker 

但是,Phusion Passenger期望您在Dockerfile中使用特殊的init进程等进行configuration更改,例如python支持。

 #FROM phusion/passenger-ruby24:<VERSION> #FROM phusion/passenger-jruby91:<VERSION> FROM phusion/passenger-nodejs:<VERSION> #FROM phusion/passenger-customizable:<VERSION> # Set correct environment variables. ENV HOME /root # Use baseimage-docker's init process. CMD ["/sbin/my_init"] # If you're using the 'customizable' variant, you need to explicitly opt-in # for features. # # NB these images are based on https://github.com/phusion/baseimage-docker, # so anything it provides is also automatically on board in the images below # (eg older versions of Ruby, Node, Python). # # Uncomment the features you want: # # Ruby support #RUN /pd_build/ruby-2.0.*.sh #RUN /pd_build/ruby-2.1.*.sh #RUN /pd_build/ruby-2.2.*.sh #RUN /pd_build/ruby-2.3.*.sh #RUN /pd_build/ruby-2.4.*.sh #RUN /pd_build/jruby-9.1.*.sh # Python support. RUN /pd_build/python.sh # Node.js and Meteor standalone support. # (not needed if you already have the above Ruby support) RUN /pd_build/nodejs.sh # ...put your own build instructions here... # Clean up APT when done. RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 

有没有办法与gitlab-ci一起使用Dockerfile? 除了apt-get install和添加shell脚本之外,还有一个很好的工作吗?

是的,创build第二个放置Dockerfile的Gitlab存储库。在那里添加一个带有脚本命令的gitlab-ci.yml文件,该命令生成修改后的图像并将其推送到您的私有registry或Gitlabembedded式Dockerregistry,例如:

script: docker build . -t http://myregistry:5000/mymodified image docker push http://myregistry:5000/mymodified

在你的其他Gitlab仓库中,相应地改变image:行:

image: http://myregistry:5000/mymodified

关于Gitlabembedded式Dockerregistry的信息可以在这里find – > 这里