I am trying to push image from GitLab registry to Heroku image registry, but I am unable to login in gitlab-ci.
Firstly, locally I was able to log in successfully. I was following this guide - https://devcenter.heroku.com/articles/container-registry-and-runtime#logging-in-to-the-registry. The log-in was successful:
docker login --username=_ --password=$HEROKU_API_KEY registry.heroku.com
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /home/dave/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
When I try to do the same in my gitlab-ci.yml file I receive error message trying both of these options:
script:
- docker login --username=_ --password=$HEROKU_API_KEY registry.heroku.com
OR
script:
- echo $HEROKU_API_KEY | docker login --username=_ --password-stdin registry.heroku.com
Error message:
Error: Cannot perform an interactive login from a non TTY device
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1
Are there other methods I should use to log in via gitlab-ci to Heroku image registry?
Update: The HEROKU_API_KEY env variable is set up correctly. It is not masked, not protected and available in all environments. I was even able to use it previously with another command to deploy, but this time I must deploy a docker container. Another command that was used:
- dpl --provider=heroku --app=my-app --api-key=$HEROKU_SECRET_KEY
That being said, I still need a solution to deploy the container from the Gitlab registry to the Heroku registry but the docker login fails.