用平台API释放Heroku容器

发布于 2025-01-20 05:35:40 字数 1290 浏览 1 评论 0原文

我正在尝试仅使用 API 而不是 Heroku CLI 将 Web 进程发布到容器中。

我知道我可以执行类似 heroku container:release web -a <> 的操作,但使用 Heroku CLI 不是一个选项,因为我正在尝试创建 GH 操作去做它。

在正确地将图像推送到heroku注册表中后,我尝试按照 Heroku 文档 的方式如下:

curl -X PATCH https://api.heroku.com/apps/$APP/formation \
            -d '{
            "updates": [
              {
                "type": "web",
                "docker_image": "$(docker inspect $IMAGE --format={{.Id}})"
              }
            ]
          }' \
            -H "Content-Type: application/json" \
            -H "Accept: application/vnd.heroku+json; version=3.docker-releases" \
            -H "Authorization: Bearer $HEROKU_API_KEY"

但是它一直给我同样的信息:

{
  "resource": "docker_image",
  "id": "not_found",
  "message": "Couldn't find that docker image."
}

我做错了什么?

注意

在我的 GH 操作中,我已经尝试执行 heroku login -i 并传递用户名和访问令牌,但它一直给我密码:无效选项 -s< /代码>。

即使我复制 HEROKU_API_KEY 环境变量,执行 docker Push ... 也会失败。

复制有效的 .netrc 文件也会失败,并出现与使用 HEROKU_API_KEY 相同的错误。

I'm trying to release a web process into a container by using only the API and not the Heroku CLI.

I know that i can do something like heroku container:release web -a <<myApp>>, but use the Heroku CLI is not an option since i'm trying to create a GH Action to do it.

After pushing correctly the image in the heroku registry, i tried to release the container doing as stated from the Heroku docs in the following way:

curl -X PATCH https://api.heroku.com/apps/$APP/formation \
            -d '{
            "updates": [
              {
                "type": "web",
                "docker_image": "$(docker inspect $IMAGE --format={{.Id}})"
              }
            ]
          }' \
            -H "Content-Type: application/json" \
            -H "Accept: application/vnd.heroku+json; version=3.docker-releases" \
            -H "Authorization: Bearer $HEROKU_API_KEY"

However it keeps giving me the same message:

{
  "resource": "docker_image",
  "id": "not_found",
  "message": "Couldn't find that docker image."
}

What am i doing wrong?

NOTES:

In my GH Action i already tried doing heroku login -i and passing username and access token, but it keeps giving me Password: invalid option -s.

Even if i copy the HEROKU_API_KEY environment variable, doing docker push ... fails.

Copying a valid .netrc file fails too with the same error of using the HEROKU_API_KEY.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空气里的味道 2025-01-27 05:35:40

如果有人像我一样陷入困境,我将在这里发布另一个解决方案。

在您的存储库中创建最简单的heroku.yml

将以下内容放在其中:

build:
  docker:
    web: Dockerfile

对我来说,不需要运行部分,因为CMD进入DockerFile已经是我需要执行的。

这样,Heroku平台就会理解必须构建图像并在构建过程完成后运行容器

If someone gets stuck like me in this i'm posting another solution here.

Create the most simple heroku.yml in your repository.

Put the following content inside it:

build:
  docker:
    web: Dockerfile

For me, there's no need for run section, since the CMD into the Dockerfile is already what i need to get executed.

In this way, heroku platform understand that must build the image and runs the container after the build process has completed

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文