Deployment on CircleCI + Docker + Heroku does not work

heroku
docker
circle.yml

#1

I am making CI environment for the first time.
Although the programming history is about two years, there is not much knowledge of the back end, Docker has used it, but the command options etc. are not well understood level.

Overview

I am trying to create an environment that will be released automatically to Heroku after being pushed to github with the combination of CircleCI + Docker + Heroku, but it will not work.
If you create a CircleCI configuration file and push it to github it will be executed
docker push properly and will end normally, but nothing will be updated on Heroku side.
I am in trouble because no error is displayed.

I will write a bit more below.

What you want to do

I’d like to create a CI environment to be executed as follows.

As a prerequisite, a dockerfile for running flask is provided in the project.

  1. push to github’s develop branch
  2. circleCI detects it and executes the test code
  3. If you pass the test, on circleCI, checkout master -> merge -> push
  4. Then deploy & release on heroku

I am doing well until step 3.

Clogged places

Below is the name of my project hoge-project . I wrote the process of pushing the Docker container from CircleCI to Heroku with reference to
this site .
Environment variables etc are properly set on CircleCI.

  deploy:
    machine:
      image: 'circleci/classic:edge'
    steps:
      - checkout
      - run:
          name: pull and push
          command: |
            git pull origin develop
            git checkout master
            git merge develop
            git push origin master
      - run:
          name: Heroku
          command: |
            docker login --username=$HEROKU_EMAIL --password=$HEROKU_API_KEY registry.heroku.com
            docker build --rm=false -t registry.heroku.com/hoge-project/web .
            docker push registry.heroku.com/hoge-project/web:latest

Then, on CircleCI, a log of a long build and Docker’s build (?) Appears,

Step 21/21 : CMD flask run -h 0.0.0.0 -p $PORT
 ---> Running in fb7574e3d053
 ---> 05c9c8397695
Successfully built 05c9c8397695
Successfully tagged registry.heroku.com/hoge-project/web:latest
The push refers to a repository [registry.heroku.com/hoge-project/web]

Processing is completed as shown in Fig.
I pasted on the last 6 lines of the log with about 9000 rows.
It seems like this ends normally on CircleCI, but when I go to Heroku, nothing has changed.
There is no error log, so it is not possible to check measures.

By the way, we are not currently working with Github on Heroku.

If you refer to this site , this site , this site, etc., you can read it as if you execute a command like
circleCI, it will feel like pushing and releasing, but Heroku’s updated version on May 29 , 2018 documents Looking at the, command until now, also it was also included and there and I was separated from it. docker push registry.heroku.com/hoge-project/web

docker push registry.heroku.com push release

So docker push after you, something release and do not have to run a command to , but I think,
for example on the circleci heroku container:release web if an attempt is made to execute the command,

Login Succeeded
 â–¸    container:release is not a heroku command.
 â–¸    Perhaps you meant container:rm
 â–¸    Run heroku help container for a list of available
 â–¸    commands.
Exited with code 127

And container:release it gets angry that there is no command to move locally .

Looking at this page it says as follows.

heroku container:. release, which creates a Heroku-compatible slug and deploys it to Heroku, has been deprecated For access to our container registry (available in private beta), please contact docker-feedback@heroku.com

container:release Has the command disappeared?
As described later, this command can be used without problems locally.
Why can not we use it on circleci?

docker push Was something after release seems necessary to the execution of the settings and commands for you, but I have unfortunately not found anything that corresponds to it even look like official documents and blogs.

Things I tried additionally

I tried adding heroku.yml with reference to this site etc.

build:
  languages:
    - python
  packages:
    - libopencv-dev
run:
  web: flask main.py

This adds one line to the deploy section of the previous circleci’s config.yml and made it as follows.

      - run:
          name: Heroku
          command: |
            docker build --rm=false -t registry.heroku.com/hoge-project/web .
            docker login --username=$HEROKU_EMAIL --password=$(heroku auth:token) registry.heroku.com
            docker push registry.heroku.com/hoge-project/web
            git push https://heroku:$HEROKU_API_KEY@git.heroku.com/hoge-project.git master

If you run circleci with this, it ends without error, and as you look at heroku the activity is updated.
view build log Looking at the following log seemingly seemingly seemingly seemingly logged is recorded.

-----> Python app detected
 !     The latest version of Python 3 is python-3.6.6 (you are using python-3.6.5, which is unsupported).
 !     We recommend upgrading by specifying the latest version (python-3.6.6).
       Learn More: https://devcenter.heroku.com/articles/python-runtimes
-----> Installing requirements with pip
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing...
       Done: 43.5M
-----> Launching...
       Released v28
       https://hoge-project.herokuapp.com/ deployed to Heroku

However, open app when you look at the application site from, Applicatoin error it is displayed.

Digression

By the way, when I run it locally with “Docker + Heroku + Flask” without circleCI I am doing fine.
$ heroku container:login
$ heroku container:push --app hoge-project web
$ heroku container:release web

If you do this you will be successfully deployed and you will see that it has also been updated in the Activity column on Heroku’s site.

$ heroku open You can browse sites created by flask on the web.

I was sorry to have told you a long time.
Would you wish to teach if someone knows of it?
Thank you for your consideration.


#2

No, it has been deprecated (i.e. discouraged). See this message:

heroku container:. release, which creates a Heroku-compatible slug and deploys it to Heroku, has been deprecated

You can if you use the right version. Usually deprecated commands are eventually removed. You could try installing an older version, but that’s probably not the best way to solve the problem - try to find out how Heroku want you to this instead.


#3

I find solution by installing heroku cli on circleci

[config.yml file]
version: 2
jobs:
build:
machine: true
steps:
- checkout
# test
- run: |
docker-compose -f docker-compose.unittests.yml run --rm unittests
# build image
- run: |
docker info
docker build -t aspnetapp DotNetCoreSampleApi
# deploy the image
- run: |
docker login -username=$HEROKU_USERNAME --password=$HEROKU_API_KEY registry.heroku.com
docker tag aspnetapp registry.heroku.com/$HEROKU_APP_NAME/web
docker push registry.heroku.com/$HEROKU_APP_NAME/web
- run:
name: Setup Heroku
command: |
chmod +x .circleci/setup-heroku.sh
.circleci/setup-heroku.sh
- run:
name: Deploy to Heroku
command: |
heroku container:release web --app $HEROKU_APP_NAME

[setup-heroku.sh]
#!/bin/bash
set -eu
git remote add heroku https://git.heroku.com/$HEROKU_APP_NAME.git
wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
cat > ~/.netrc << EOF
machine api.heroku.com
login $HEROKU_LOGIN
password $HEROKU_API_KEY
machine git.heroku.com
login $HEROKU_LOGIN
password $HEROKU_API_KEY
EOF
chmod 600 ~/.netrc

Add heroku.com to the list of known hosts

ssh-keyscan -H heroku.com >> ~/.ssh/known_hosts


#4

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.