Deploy docker container from external registry to Heroku

后端 未结 2 819
深忆病人
深忆病人 2021-02-05 22:50

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.

2条回答
  •  温柔的废话
    2021-02-05 23:09

    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= 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.

提交回复
热议问题