Heroku Container Releaseで気をつけること

シレッとそれなりの数の制限がある。特に影響の大きいものを挙げる。

Container Registry & Runtime (Docker Deploys) | Heroku Dev Center

deployログを確認したければimageにcurlを足すべし

If you would like to see streaming logs as release phase executes, your Docker image is required to have curl. If your Docker image does not include curl, release phase logs will only be available in your application logs.

入っていないと Heroku の Activity では何も確認できない。当然、エラーの様子も分からない。Log Drain 側には出ているが、意識から外れると release 時の問題についてデバッグ不能になる。

Dockerfileで使えないもの

  • VOLUME - Volume mounting is not supported. The filesystem of the dyno is ephemeral.
  • EXPOSE - While EXPOSE can be used for local testing, it is not supported in Heroku’s container runtime. Instead your web process/code should get the $PORT environment variable.
  • STOPSIGNAL - The dyno manager will request that your processes shut down gracefully by sending them a SIGTERM signal followed by a SIGKILL signal. STOPSIGNAL is not respected.
  • SHELL - The default shell for Docker images is /bin/sh, you can override with ENTRYPOINT if necessary.
  • HEALTHCHECK - While HEALTHCHECK is not currently supported, the Heroku Dyno manager automatically checks the health of your running containers.

まぁこれはそうかなという感じ。

OCI Image非対応

The Heroku Container Registry only supports Docker Image Manifest V2, Schema 2 (application/vnd.docker.distribution.manifest.v2+json). It doesn’t support other manifest types, such as OCI Image Manifest (application/vnd.oci.image.manifest.v1+json).

したがって自動的に Cloud Native Buildpacks で build した image は非対応。どういうことですかね…。

Cloud Native Buildpacks · Cloud Native Buildpacks

Cloud Native Buildpacks embrace modern container standards, such as the OCI image format. They take advantage of the latest capabilities of these standards, such as cross-repository blob mounting and image layer “rebasing” on Docker API v2 registries.

Cloud Native Buildpacks はモダンな OCI イメージフォーマットを採用している。

Heroku は

heroku/cnb-builder-images: Recipes for building Heroku’s Cloud Native Buildpacks builder images

にあるように Cloud Native Buildpacks に適応した buildpack もリリースしている。これを実際に試してみると分かるが、Heroku Docker Registry に成果物のイメージを push することはできるが、release すると正常に動作しない。

公式リリースの

Heroku Cloud Native Buildpacks: Bringing Heroku Magic to Container Images | Heroku

を見ると

The Heroku Cloud Native Buildpacks preview release is just the tip of the iceberg. We’re so excited for you to try them even though our platform won’t officially support them until later this year. Get ahead of the curve and experiment with Heroku CNBs today. We’re eager to hear your thoughts and see what you create with them. Head over to the project on GitHub and join us in shaping the future of application packaging!

今年(2024年)後半までは公式にはサポートしないよ、ということでした。半年後には状況は変わっているかも。

More