将docker容器从外部注册表部署到Heroku [英] Deploy docker container from external registry to Heroku
问题描述
我试图从这个问题中解决这个问题:如何使用Jhipster,Docker,Gitlab和Heroku构建,测试和部署
这是我的 .gitlab-ci.yaml
如下所示:
stage:
- build
- package
- deploy
build_npm:
image:节点:最新
stage:build
脚本:
- npm install
- npm run build:prod
工件:
路径:
- dist /
build_image:
image:docker:最新
服务:
- docker:dind
stage:package
script:
- docker login -u gitlab-ci-token -p $ CI_BUILD_TOKEN registry.gitlab.com
- docker build -t registry.gitlab.com/maciejsobala/myApp。
- docker push registry.gitlab.com/maciejsobala/myApp:latest
deploy_to_heroku:
stage:deploy
services:
- docker:dind
脚本:
- gem install dpl
- docker运行registry.gitlab.com/maciejsobala/myApp:latest
- dpl --provider = heroku --app = myApp --api-key = $ HEROKU_API_KEY
我想要实现的是,有3个阶段:
- build:此时,只编译npm项目(将来,我
想添加一些jar
这里) - 包:创建并推送到注册表Docker映像。
- 部署:在heroku上安装docker image。
我遇到了最后一个问题stage( deploy
)。说实话,我不太确定,这里应该做什么。
我试图使用dpl,关于本教程: https://docs.gitlab.com/ce/ci/examples /test-and-deploy-ruby-application-to-heroku.html
Unfornatelly尝试运行docker image时遇到问题
$ docker run registry.gitlab.com/maciejsobala/myApp:latest
/ bin / bash:line 49:docker:command没有找到
我在这里完全失明。我真的很感激任何解决方案,链接到文章/教程等。
你是由于某些原因启动应用程序(使用 docker run
)你可能不需要。 dpl
工具旨在在代码库中使用,而不是用于图像部署。正如你所说
build_image:
image:docker:最新
服务:
- :dind
stage:package
script:
- docker login -u gitlab-ci-token -p $ CI_BUILD_TOKEN registry.gitlab.com
- docker build -t registry.gitlab .com / maciejsobala / myApp。
- docker push registry.gitlab.com/maciejsobala/myApp:latest
正在工作,什么意思是你的跑步者能够在码头运营码头工程师,并成功地推动图像。根据,为了英雄部署,您只能将该图像推送到英雄码头服务器注册表官方heroku文件。简而言之,你做一个
deploy_to_heroku:
stage:deploy
services:
- docker :dind
script:
- docker login --email = _ --username = _ --password =< YOUR-HEROKU-AUTH-TOKEN> registry.heroku.com
- docker tag registry.gitlab.com/maciejsobala/myApp:latest registry.heroku.com/maciejsobala/myApp:latest
- docker push registry.heroku.com/maciejsobala/myApp :最新
与您的英雄认证标记,您可以通过 heroku auth :令牌
如文档所述,推送到herokus注册表触发应用程序的发布过程。
I got project repository hosted on gitlab. I am using gitlab-ci to build docker container from my project. What I would like to achieve is deploying that container to heroku.
I was trying to follow solution from this question: How to build, test and deploy using Jhipster, Docker, Gitlab and Heroku
Here is how my .gitlab-ci.yaml
looks like:
stages:
- build
- package
- deploy
build_npm:
image: node:latest
stage: build
script:
- npm install
- npm run build:prod
artifacts:
paths:
- dist/
build_image:
image: docker:latest
services:
- docker:dind
stage: package
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
- docker build -t registry.gitlab.com/maciejsobala/myApp .
- docker push registry.gitlab.com/maciejsobala/myApp:latest
deploy_to_heroku:
stage: deploy
services:
- docker:dind
script:
- gem install dpl
- docker run registry.gitlab.com/maciejsobala/myApp:latest
- dpl --provider=heroku --app= myApp --api-key=$HEROKU_API_KEY
What I am trying to achieve is, have 3 stages:
- build: at this moment, compile only npm project (in the future, I
want to add some
jar
here) - package: create and push to registry docker image.
- deploy: install docker image on heroku.
I am running into issues with the last stage (deploy
). To be honest I am not really sure, what should be done here.
I tried to use dpl, regarding to this tutorial: https://docs.gitlab.com/ce/ci/examples/test-and-deploy-ruby-application-to-heroku.html
Unfornatelly I am running into issues when trying to run docker image
$ docker run registry.gitlab.com/maciejsobala/myApp:latest
/bin/bash: line 49: docker: command not found
I am completely blind here. I would really appreciate any solutions, links to articles/tutorials etc.
You are starting the app for some reason (using docker run
) you might don't need. The dpl
tool is intended to be used inside a codebase, rather than for image deployment. As you said
build_image:
image: docker:latest
services:
- docker:dind
stage: package
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
- docker build -t registry.gitlab.com/maciejsobala/myApp .
- docker push registry.gitlab.com/maciejsobala/myApp:latest
is working, what means your runner is able to run docker in docker and successfully pushing images. For heroku deployment, you must only push that image to the heroku docker registry, according to the official heroku documentation. In short you do a
deploy_to_heroku:
stage: deploy
services:
- docker:dind
script:
- docker login --email=_ --username=_ --password=<YOUR-HEROKU-AUTH-TOKEN> registry.heroku.com
- docker tag registry.gitlab.com/maciejsobala/myApp:latest registry.heroku.com/maciejsobala/myApp:latest
- docker push registry.heroku.com/maciejsobala/myApp:latest
with your heroku auth token, which you can get by heroku auth:token
As said in the documentation, pushing to herokus registry triggers a release process of the app.
这篇关于将docker容器从外部注册表部署到Heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!