简体   繁体   English

使用Gitlab CI将节点应用构建并部署到Openshift

[英]Build and deploy node app to Openshift using Gitlab CI

Just mount a Gitlab in digitalocean to keep track of versions of some projects, but now I've read a little about Gitlab I wonder if you can set Gitlab CI so that each time you do a commit automatically make a build of application and if the build is successful can do a deploy to OpenShift. 只需在digitalocean中安装一个Gitlab来跟踪某些项目的版本,但是现在我对Gitlab有了一些了解,我想知道是否可以设置Gitlab CI,以便每次执行提交时都会自动构建应用程序,并且是否构建成功可以部署到OpenShift。

I think my .gitlab-ci.yml should look something like this: 我认为.gitlab-ci.yml应该看起来像这样:

stages:
  - build
  - deploy

before_script:
  - npm install

job_build:
  stage: build
  script:
    - grunt build

job_deploy:
  stage: deploy

But I really do not know if this is as valid and neither tell Gitlab CI must only make a git push to OpenShift repository. 但是我真的不知道这是否有效,也没有告诉Gitlab CI必须将git push到OpenShift存储库。

After much reading and searching finally found documentation about this [1], in the end I have resolved some file using the following .gitlab-ci.yml 经过大量的阅读和搜索,最终找到了有关此文档的文档[1],最后,我使用以下.gitlab-ci.yml解决了一些文件

stages:
  - build
  - deploy

job_build:
  stage: build
  script:
    - npm install -g grunt-cli
    - npm rebuild node-sass
    - npm install
    - grunt build

job_deploy:
  stage: deploy
  script:
    - apt-get update -yq
    - apt-get install -y ruby-dev rubygems
    - gem install dpl
    - dpl --provider=openshift --user=$OPENSHIFT_USER --password=$OPENSHIFT_PASS --domain=mydomain --app=example
  only:
    - master

The magic happens with a Travis library call dpl [2] that supports a lot of providers [3] Travis库调用dpl [2](支持许多提供程序[3])使魔术发生了变化

[1] http://doc.gitlab.com/ce/ci/deployment/README.html [1] http://doc.gitlab.com/ce/ci/deployment/README.html

[2] https://github.com/travis-ci/dpl [2] https://github.com/travis-ci/dpl

[3] https://github.com/travis-ci/dpl#supported-providers [3] https://github.com/travis-ci/dpl#supported-providers

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Gitlab CI将每个构建部署到服务器 - Deploy every build to a server using Gitlab CI 无法将Node应用程序部署到Openshift - Unable to deploy Node app to Openshift 用于 GAE 的 React App + Node Gitlab cicd 管道(构建和部署) - React App + Node Gitlab cicd pipeline for GAE (Build and Deploy) gitlab.com CI-在docker中使用docker构建NodeJS应用 - gitlab.com CI - build a NodeJS app using docker in docker 如何在openshift上部署并运行节点应用程序? - How to deploy node app on openshift and run it? Red Hat OpenShift:无法构建/部署节点应用程序,因为“输出图像无法解析” - Red Hat OpenShift: cannot build/deploy node app because “Output image could not be resolved” Gitlab CI/CD - 在 Azure 上部署节点应用程序 Linux WebApp - Gitlab CI/CD - deploy node application on Azure Linux WebApp 使用 gitlab ci cd 管道时访问节点 js 应用程序中的 env 变量 - Access env variables in node js app when using gitlab ci cd pipeline 使用 Github 操作构建 Node/Express 并部署到 Azure Web 应用程序 - Build Node/Express using Github Actions and deploy to Azure Web App 为 React App 构建的 Docker 在 Gitlab CI runner 中失败 - Docker build for React App failing in Gitlab CI runner
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM