Deploy the docker container from the external registry in Heroku

I have a project repository hosted on gitlab. I am using gitlab-ci to build a docker container from my project. What I would like to achieve is the deployment of this container in the hero.

I tried to implement a solution on this: How to create, test and deploy using Jhipster, Docker, Gitlab and Heroku .

Here's what mine looks like .gitlab-ci.yaml:

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'm trying to achieve consists of three stages:

  • build: for now, only compile the npm project (in the future, I want to add here jar)
  • package: create and click on the image docker registry.
  • deploy: install the docker image on the hero.

(deploy). , , .

dpl : https://docs.gitlab.com/ce/ci/examples/test-and-deploy-ruby-application-to-heroku.html

Unfornatelly

$ docker run registry.gitlab.com/maciejsobala/myApp:latest
/bin/bash: line 49: docker: command not found

. , / ..

+4
1

- ( docker run), . dpl , .

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

, , . heroku - 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:latest

, heroku auth:token

, herokus .

+5

Source: https://habr.com/ru/post/1671534/


All Articles