Container Registry ããã³ Runtime (Docker ãããã¤)
ãã®è¨äºã®è±èªçã«æ´æ°ãããã¾ããã覧ã®ç¿»è¨³ã«ã¯å«ã¾ãã¦ããªãå¤æ´ç¹ãããããããã¾ããã
æçµæ´æ°æ¥ 2024å¹´04æ30æ¥(ç«)
Table of Contents
- ã¯ããã«
- ã¬ã¸ã¹ããªã¸ã®ãã°ã¤ã³
- ã¤ã¡ã¼ã¸ã®ãã«ãã¨ããã·ã¥
- ã¤ã¡ã¼ã¸ã®ãªãªã¼ã¹
- One-off dyno
- CI/CD ãã©ãããã©ã¼ã ã®ä½¿ç¨
- Release Phase
- Dockerfile ã³ãã³ãã¨ã©ã³ã¿ã¤ã
- ãã¼ã«ã«ã§ã®ã¤ã¡ã¼ã¸ã®ãã¹ã
- Heroku ãã¼ã¹ã¤ã¡ã¼ã¸
- ãããã¤æ¹æ³ã®å¤æ´
- æ¢ç¥ã®åé¡ã¨å¶éäºé
Heroku Container Registry ã使ç¨ããã¨ãDocker ã¤ã¡ã¼ã¸ã Heroku ã«ãããã¤ã§ãã¾ããCommon Runtimeâ 㨠Private Spaceâ ã®ä¸¡æ¹ããµãã¼ãããã¦ãã¾ãã
Heroku 㧠Docker ã¤ã¡ã¼ã¸ããã«ããããå ´åã¯ãã¬ãã¥ã¼ã¢ããªãæ´»ç¨ããã ãã§ãªããheroku.yml 㧠Docker ã¤ã¡ã¼ã¸ã®ãã«ãâã確èªãã¾ãã
Heroku container
â ã¹ã¿ãã¯âã¯ãé«åº¦ãªã¦ã¼ã¹ã±ã¼ã¹ã®ã¿ãæ³å®ãã¦ãã¾ããã«ã¹ã¿ã Docker ã¤ã¡ã¼ã¸ãç¹ã«å¿
è¦ãªå ´åãé¤ãã
Heroku ã®ããã©ã«ã buildpackâ ãå©ç¨ãããã«ãã·ã¹ãã ã代ããã«ä½¿ç¨ãããã¨ããå§ããã¾ããããã«ããã
ãã¼ã¹ã¤ã¡ã¼ã¸ã®èªåã»ãã¥ãªãã£æ´æ°ãè¨èªåºæã®æé©åãæä¾ãããDockerfile
â ãä¿å®ããå¿
è¦ããªããªãã¾ãã
ã¯ããã«
ä½æ¥ç¨ Docker ã¤ã³ã¹ãã¼ã«ããããã¨ã確èªã (docker ps
â ãªã©)ãHeroku ã«ãã°ã¤ã³ãã¦ãããã¨ã確èªãã¾ã (heroku login
â)ã
Container Registr ã«ãã°ã¤ã³ãã¾ãã
$ heroku container:login
Alpine ãã¼ã¹ã® python ä¾ãè¤è£½ãããã¨ã«ãããµã³ãã«ã³ã¼ããåå¾ãã¾ãã
$ git clone https://github.com/heroku/alpinehelloworld.git
ã¢ããªã®ãã£ã¬ã¯ããªã«ç§»åãã¦ãHeroku ã¢ããªãä½æãã¾ãã
$ cd alpinehelloworld
$ heroku create
Creating salty-fortress-4191... done, stack is heroku-20
https://salty-fortress-4191.herokuapp.com/ | https://git.heroku.com/salty-fortress-4191.git
ã¤ã¡ã¼ã¸ããã«ãããContainer Registry ã«ããã·ã¥ãã¾ãã
$ heroku container:push web
ç¶ãã¦ã¤ã¡ã¼ã¸ãã¢ããªã«ãªãªã¼ã¹ãã¾ãã
$ heroku container:release web
次ã«ãã¢ããªããã©ã¦ã¶ã§éãã¾ãã
$ heroku open
ã¬ã¸ã¹ããªã¸ã®ãã°ã¤ã³
Heroku ã¯ãregistry.heroku.com
â ã§ã³ã³ããã¬ã¸ã¹ããªãå®è¡ãã¾ãã
Heroku CLI ã使ç¨ãã¦ããå ´åã次ã®ããã«æå®ãã¦ãã°ã¤ã³ã§ãã¾ãã
$ heroku container:login
ã¾ãã¯ç´æ¥ Docker CLI ã使ç¨ãã¾ãã
$ docker login --username=_ --password=$(heroku auth:token) registry.heroku.com
ã¤ã¡ã¼ã¸ã®ãã«ãã¨ããã·ã¥
ã¤ã¡ã¼ã¸ã®ãã«ãã¨ããã·ã¥
ã¤ã¡ã¼ã¸ããã«ãã㦠Container Registry ã«ããã·ã¥ããã«ã¯ããã£ã¬ã¯ããªã« Dockerfile ãå«ã¾ãã¦ãããã¨ã確èªãã次ã®ããã«å®è¡ãã¾ãã
$ heroku container:push <process-type>
æ¢åã®ã¤ã¡ã¼ã¸ã®ããã·ã¥
Docker Hub ãããã«ãããã®ãªã©ã®ã¤ã¡ã¼ã¸ã Heroku ã«ããã·ã¥ããã«ã¯ã次ã®å½åãã³ãã¬ã¼ãã«å¾ã£ã¦ããã®ã¤ã¡ã¼ã¸ã«ã¿ã°ãä»ãããã·ã¥ãã¾ãã
$ docker tag <image> registry.heroku.com/<app>/<process-type>
$ docker push registry.heroku.com/<app>/<process-type>
ã¿ã°ã§ããã»ã¹ã¿ã¤ããæå®ãããã¨ã«ãããCLI ã使ç¨ãã¦ã¤ã¡ã¼ã¸ããªãªã¼ã¹âã§ãã¾ããã¿ã°ã§ããã»ã¹ã¿ã¤ããæå®ããªãå ´åã¯ãimage_id
â ã使ç¨ãã API ãä»ãã¦ãªãªã¼ã¹âããå¿
è¦ãããã¾ãã
è¤æ°ã®ã¤ã¡ã¼ã¸ã®ããã·ã¥
è¤æ°ã®ã¤ã¡ã¼ã¸ãããã·ã¥ããã«ã¯ãDockerfile.<process-type>
â ã使ç¨ã㦠Dockerfile ã®ååãå¤æ´ãã¾ãã
$ ls -R
./webapp:
Dockerfile.web
./worker:
Dockerfile.worker
./image-processor:
Dockerfile.image
次ã«ãããã¸ã§ã¯ãã®ã«ã¼ããã£ã¬ã¯ããªããã次ã®ããã«å®è¡ãã¾ãã
$ heroku container:push --recursive
=== Building web
=== Building worker
=== Building image
=== Pushing web
=== Pushing worker
=== Pushing image
ããã¯ã3 ã¤ã®ã¤ã¡ã¼ã¸ãã¹ã¦ããã«ããã¦ããã·ã¥ãã¾ããç¹å®ã®ã¤ã¡ã¼ã¸ã ããããã·ã¥ããå ´åã¯ãããã»ã¹ã¿ã¤ããæå®ã§ãã¾ãã
$ heroku container:push web worker --recursive
=== Building web
=== Building worker
=== Pushing web
=== Pushing worker
ã¤ã¡ã¼ã¸ã®ãªãªã¼ã¹
CLI
Container Registry ã«æ£å¸¸ã«ã¤ã¡ã¼ã¸ãããã·ã¥ããå¾ã次ã®ã³ãã³ãã使ç¨ãã¦æ°ãããªãªã¼ã¹ãä½æã§ãã¾ãã
$ heroku container:release web
è¤æ°ã®ã¤ã¡ã¼ã¸ãããå ´åã¯ãããããä¸è¦§è¡¨ç¤ºãã¾ãã
$ heroku container:release web worker
è¤æ°ã®ããã»ã¹ã¿ã¤ããæã¤ã¢ããªã§ã¯ã1 ã¤ã®ããã»ã¹ã¿ã¤ã (heroku container:release web
â ãªã©) ã ãããªãªã¼ã¹ããå ´åããã¹ã¦ã®ããã»ã¹ã¿ã¤ããåèµ·åããã¾ãã
API
curl --netrc -X PATCH https://api.heroku.com/apps/$APP_ID_OR_NAME/formation \
-d '{
"updates": [
{
"type": "web",
"docker_image": "$WEB_DOCKER_IMAGE_ID"
},
{
"type": "worker",
"docker_image": "$WORKER_DOCKER_IMAGE_ID"
}
]
}' \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.heroku+json; version=3.docker-releases"
curl --netrc
â ãªãã·ã§ã³ãæ©è½ããããã«ããã«ã¯ãheroku login
â ãäºåã«å®è¡ã㦠.netrc
â ãã¡ã¤ã«ã® API ãã¼ã¯ã³ãè¨å®ããå¿
è¦ãããã¾ãã
Docker ã¤ã¡ã¼ã¸ ID ã®åå¾
ãã©ãããã©ã¼ã API ãä»ãã¦ã¤ã¡ã¼ã¸ããªãªã¼ã¹ããã¨ãã«ä½¿ç¨ããã docker ã¤ã¡ã¼ã¸ã®å¤ã¯ãalgorithm:hex
â å½¢å¼ã§ããå¿
è¦ãããã¾ãã次ã«ä¾ã示ãã¾ãã
sha256:4d2647aab0e8fbe92cb0fc88c500eb51661c5907f4f14e79efe8bfbda1f7d159
ã¤ã¡ã¼ã¸ã®ããã«ãã® ID ãåå¾ããã«ã¯ã次ã®ã³ãã³ããå®è¡ãã¾ãã
$ docker inspect my_image --format={{.Id}}
sha256:4d2647aab0e8fbe92cb0fc88c500eb51661c5907f4f14e79efe8bfbda1f7d159
One-off dyno
ã¢ããªãè¤æ°ã® Docker ã¤ã¡ã¼ã¸ããæ§æããã¦ããå ´åãOne-off dyno ãä½æããã¨ãã«ããã»ã¹ã¿ã¤ãã対象ã«ãããã¨ãã§ãã¾ã
$ heroku run bash --type=worker
Running bash on ⬢ multidockerfile... up, worker.5180
$
ã¿ã¤ããæå®ããã¦ããªãå ´åãweb
â ã¤ã¡ã¼ã¸ã使ç¨ããã¾ãã
CI/CD ãã©ãããã©ã¼ã ã®ä½¿ç¨
ç¾å¨ãHeroku CI ã使ç¨ãã¦ã³ã³ãããã«ãããã¹ããããã¨ã¯ã§ãã¾ããã
ãµã¼ããã¼ãã£è£½ã® CI/CD ãã©ãããã©ã¼ã ã使ç¨ãã¦ããå ´åã¯ãã¬ã¸ã¹ããªã«ã¤ã¡ã¼ã¸ãããã·ã¥ã§ãã¾ããæåã«æ¬¡ã®æ å ±ã§èªè¨¼ãã¾ãã
- ã¬ã¸ã¹ã㪠URL: â
registry.heroku.com
- ã¦ã¼ã¶ã¼å: â
your Heroku email address
- ã¡ã¼ã«: â
your Heroku email address
- ãã¹ã¯ã¼ã: â
your Heroku API key
å¤ãã® CI/CD ãããã¤ãã¼ã¯ãã¤ã¡ã¼ã¸ããã«ãã㦠Docker ã¬ã¸ã¹ããªã«ããã·ã¥ããæ¹æ³ã«é¢ããããã¥ã¡ã³ããç¨æãã¦ãã¾ãã
Release Phase
Release Phaseâ ã使ç¨ããã«ã¯ãrelease
â ã¨ããååã® Docker ã¤ã¡ã¼ã¸ãããã·ã¥ãã¾ãã
$ heroku container:push release
Docker ã¤ã¡ã¼ã¸ããªãªã¼ã¹ããã¨ãheroku container:release
â ãå®è¡ãããã¨ã«ãããRelease Phase ããã»ã¹ã¿ã¤ããæå®ããå¿
è¦ãããã¾ãã
$ heroku container:release web release
Releasing images web,release to your-app-name... done
Running release command...
Migrating database.
Release Phase ãå®è¡ããã¨ãã«ã¹ããªã¼ãã³ã°ãã°ã確èªããå ´åã¯ãDocker ã¤ã¡ã¼ã¸ã« curl
â ãå¿
è¦ã§ããDocker ã¤ã¡ã¼ã¸ã« curl
â ãå«ã¾ãã¦ããªãå ´åãã¢ããªã±ã¼ã·ã§ã³ãã°ã§ã®ã¿ Release Phase ãã°ã使ç¨ã§ãã¾ãã
Dockerfile ã³ãã³ãã¨ã©ã³ã¿ã¤ã
Docker ã¤ã¡ã¼ã¸ã¯ãdyno ã«ããã¦ãslugs ãè¡ãæ¹æ³ã¨åãããã«âåãå¶ç´ã®ãã¨å®è¡ãã¾ãã
- Web ããã»ã¹ã¯ãHeroku ã«ããè¨å®ããã
$PORT
â ä¸ã§ HTTP ãã©ãã£ãã¯ããªã¹ã³ããå¿ è¦ãããã¾ããDockerfile
âå ã®EXPOSE
â ã¯èæ ®ããã¾ãããããã¼ã«ã«ãã¹ãã«ä½¿ç¨ã§ãã¾ããHTTP ãªã¯ã¨ã¹ãã ãããµãã¼ãããã¦ãã¾ãã - dyno ã®ãããã¯ã¼ã¯ãªã³ã¯ã¯ãµãã¼ãããã¦ãã¾ããã
- ãã¡ã¤ã«ã·ã¹ãã ã¯ä¸æçã§ãã
- ä½æ¥ç¨ãã£ã¬ã¯ããªã¯
/
â ã§ããWORKDIR
âã使ç¨ãã¦ãå¥ã®ãã£ã¬ã¯ããªãè¨å®ã§ãã¾ãã - ç°å¢å¤æ°ãè¨å®ããããã®
ENV
â ããµãã¼ãããã¦ãã¾ãã- ã©ã³ã¿ã¤ã å¤æ° (
GEM_PATH
â ãªã©) ã«ENV
â ããè³æ ¼æ å ±ã«heroku config
â ã使ç¨ãããã¨ããå§ããã¾ããããããã°ãæ©å¯æ§ã®ããè³æ ¼æ å ±ã誤ã£ã¦ã½ã¼ã¹ã³ã¼ãå¶å¾¡ã«ãã§ãã¯ã¤ã³ããããã¨ããªããªãã¾ãã
- ã©ã³ã¿ã¤ã å¤æ° (
ENTRYPOINT
â ã¯ãªãã·ã§ã³ã§ããè¨å®ããã¦ããªãå ´åã/bin/sh -c
â ã使ç¨ããã¾ããCMD
â ã¯å¸¸ã«ã·ã§ã«ã«ããå®è¡ãããã®ã§ãç°å¢è¨å®âã¯ããã»ã¹ã§ä½¿ç¨å¯è½ã«ãªãã¾ããåä¸ã®ãã¤ããªãå®è¡ããããã·ã§ã«ãªãã§ã¤ã¡ã¼ã¸ã使ç¨ããã«ã¯ãENTRYPOINT
â ã使ç¨ãã¦ãã ããã
ã³ã³ããã¯ãHeroku ã®ã«ã¼ã権éã§å®è¡ããã¦ããªãâã®ã§ãéã«ã¼ãã¦ã¼ã¶ã¼ã¨ãã¦ãã¼ã«ã«ã§ã¤ã¡ã¼ã¸ããã¹ããããã¨ãå¼·ããå§ããã¾ãã
æªãµãã¼ãã® Dockerfile ã³ãã³ã
VOLUME
â - ããªã¥ã¼ã ãã¦ã³ãã£ã³ã°ã¯ãµãã¼ãããã¦ãã¾ãããdyno ã®ãã¡ã¤ã«ã·ã¹ãã ã¯ä¸æçã§ãâãEXPOSE
â -EXPOSE
â ã¯ãã¼ã«ã«ãã¹ãã«ä½¿ç¨ã§ãã¾ãããHeroku ã®ã³ã³ããã©ã³ã¿ã¤ã ã§ã¯ãµãã¼ãããã¦ãã¾ããã代ããã«ãWeb ããã»ã¹/ã³ã¼ã㧠$PORT ç°å¢å¤æ°ãåå¾ããå¿ è¦ãããã¾ããSTOPSIGNAL
â - dyno ããã¼ã¸ã£ã¼ã¯ãSIGTERM ä¿¡å·âã¨ããã«ç¶ã SIGKILL ä¿¡å·ãéä¿¡ãããã¨ã«ãããããã»ã¹ãã°ã¬ã¼ã¹ãã«ã·ã£ãããã¦ã³ãè¡ãããã«è¦æ±ãã¾ããSTOPSIGNAL
âã¯èæ ®ããã¾ãããSHELL
â - Docker ã¤ã¡ã¼ã¸ã®ããã©ã«ãã®ã·ã§ã«ã¯/bin/sh
â ã§ãããå¿ è¦ã«å¿ãã¦ENTRYPOINT
â ã§ä¸æ¸ãã§ãã¾ããHEALTHCHECK
â -HEALTHCHECK
â ã¯ç¾å¨ãµãã¼ãããã¦ãã¾ããããHeroku Dyno ããã¼ã¸ã£ã¼ãèªåçã«ãå®è¡ä¸ã®ã³ã³ããã®ãã«ã¹ã確èªãã¾ãã
ãã¼ã«ã«ã§ã®ã¤ã¡ã¼ã¸ã®ãã¹ã
ãã¼ã«ã«ã§ã¤ã¡ã¼ã¸ããã¹ãããã¨ãã«ãå¤æ°ã®ãã¹ããã©ã¯ãã£ã¹ãããã¾ãããããã®ãã¹ããã©ã¯ãã£ã¹ã¯ããã® Dockerfile ä¾âã«å®è£ ããã¦ãã¾ãã
éã«ã¼ãã¦ã¼ã¶ã¼ã¨ãã¦ã®ã¤ã¡ã¼ã¸ã®å®è¡
ã³ã³ããã¯ãHeroku ã®ã«ã¼ã権éã§å®è¡ããã¦ããªãã®ã§ãéã«ã¼ãã¦ã¼ã¶ã¼ã¨ãã¦ãã¼ã«ã«ã§ã¤ã¡ã¼ã¸ããã¹ããããã¨ãå¼·ããå§ããã¾ããCMD
âã®ç´åã«ã次ã®ã³ãã³ãã Dockerfile ã«è¿½å ã§ãã¾ãã
Alpine ã使ç¨ãã¦ããå ´å:
RUN adduser -D myuser
USER myuser
Ubuntu ã使ç¨ãã¦ããå ´å:
RUN useradd -m myuser
USER myuser
ã³ã³ãããéã«ã¼ãã¦ã¼ã¶ã¼ã¨ãã¦å®è¡ãã¦ãããã¨ã確èªããã«ã¯ãå®è¡ä¸ã®ã³ã³ããã«ã¢ã¿ãããã¦ãããwhoami
â ã³ãã³ããå®è¡ãã¾ãã
$ docker exec <container-id> bash
$ whoami
myuser
Heroku ã«ãããã¤ããã¨ãéã«ã¼ãã¦ã¼ã¶ã¼ã¨ãã¦ãã³ã³ãããå®è¡ãã¾ã (ãã ããDockerfile ã§æå®ããã USER
â ã¯ä½¿ç¨ãã¾ãã)ã
$ heroku run bash
$ whoami
U7729
ç°å¢å¤æ°ããã®ãã¼ãã®åå¾
ãã¹ãã®ããã«ããã¨ãã°æ¬¡ã®ããã«ãDockerfile
â ã¾ãã¯ã³ã¼ãã $PORT ç°å¢å¤æ°ããèªã¿åããã¨ããå§ããã¾ãã
CMD gunicorn --bind 0.0.0.0:$PORT wsgi
Docker ã³ã³ããããã¼ã«ã«ã§å®è¡ãã¦ããå ´åã-e ãã©ã°ã使ç¨ãã¦ç°å¢å¤æ°ãè¨å®ã§ãã¾ãã
$ docker run -p 5000:5000 -e PORT=5000 <image-name>
è¤æ°ã®ç°å¢å¤æ°ã®è¨å®
ãã¼ã«ã«ã§ Heroku ã使ç¨ããå ´åã.env ãã¡ã¤ã«âã§ç°å¢è¨å®ãè¨å®ã§ãã¾ããheroku local
âãå®è¡ãããã¨ã.env ãèªã¿åãããå name/value ã®ãã¢ãç°å¢ã§è¨å®ããã¾ããDocker ã使ç¨ããã¨ãã«ããã®åã .env ãã¡ã¤ã«ã使ç¨ã§ãã¾ãã
$ docker run -p 5000:5000 --env-file .env <image-name>
.env ãã¡ã¤ã«ã .dockerignore ãã¡ã¤ã«âã«è¿½å ãããã¨ããå§ããã¾ãã
ãã«ãã³ã³ããã¢ããªã±ã¼ã·ã§ã³ã«å¯¾ãã Docker Compose ã®å©ç¨
ãã«ãã³ã³ããã¢ããªã±ã¼ã·ã§ã³ãä½æããå ´åãDocker Compose ã使ç¨ãã¦ããã¼ã«ã«ã®éçºç°å¢ãå®ç¾©ã§ãã¾ãããã¼ã«ã«éçºã« Docker Compose ã使ç¨âããæ¹æ³ã«ã¤ãã¦èª¬æãã¾ãã
追å æ å ±
- ãã¼ã«ã«ã§ã® Docker ã¤ã¡ã¼ã¸ã®å®è¡ã«é¢ãã詳細ã¯ãDocker ã®å ¬å¼ããã¥ã¡ã³ãâã«è¨è¿°ããã¦ãã¾ãã
- ãã¼ã«ã«éçºã« Docker Composeâ ã使ç¨ããæ¹æ³ã«ã¤ãã¦èª¬æãã¾ãã
- Docker ã¤ã¡ã¼ã¸ã®ãã«ãããã©ã¼ãã³ã¹ããã³ãµã¤ãºãæé©åããæ¹æ³ã®ãã³ãã«ã¤ãã¦ã¯ãDockerfile ãæ¸ãè¾¼ãããã®ãã¹ããã©ã¯ãã£ã¹âã®ã¬ã¤ããåç §ãã¦ãã ããã
Heroku ãã¼ã¹ã¤ã¡ã¼ã¸
Heroku ã®ã¹ã¿ãã¯âã¯ãå©ä¾¿æ§ãåä¸ããããã Docker ãã¼ã¹ã¤ã¡ã¼ã¸ã¨ãã¦å©ç¨ã§ãã¾ã (Docker ã¤ã¡ã¼ã¸ã®ååã¨ã¿ã°ã«ã¤ãã¦ã¯ãåã¹ã¿ãã¯ã®è©³ç´°ãã¼ã¸ãåç §ãã¦ãã ãã)ããã ãããã«ãããã³èµ·åæéãæçã«ããã«ã¯ãã¢ããªã®è¨èªã«ã¤ãã¦ããããã®å ¬å¼ã® Docker ã¤ã¡ã¼ã¸âãªã©ãããå°ããæ±ç¨æ§ã®ä½ããã¼ã¹ã¤ã¡ã¼ã¸ã代ããã«ä½¿ç¨ãããã¨ãå¼·ããå§ããã¾ãã
ãããã¤æ¹æ³ã®å¤æ´
Container Registry ãä»ãã¦ã¢ããªã±ã¼ã·ã§ã³ããããã¤ããã¨ãã¹ã¿ãã¯ã¯ container
â ã«è¨å®ããã¾ããããã¯ãã¢ããªã±ã¼ã·ã§ã³ã Heroku-curated ã¹ã¿ãã¯âã使ç¨ããªããªã£ããã代ããã«èªèº«ã®ã«ã¹ã¿ã ã³ã³ããã使ç¨ãã¦ãããã¨ãæå³ãã¾ãã
ã¢ããªã«å¯¾ã㦠Docker ã¤ã¡ã¼ã¸ã使ç¨ããå¿
è¦ããªããªããHeroku-curated ã¹ã¿ãã¯ã使ç¨ãã buildpack ãã¼ã¹ã®ãããã¤ã«åãæ¿ãã¦æ»ãå ´åãheroku stack:set
â ã³ãã³ãã使ç¨ãã¦ã使ç¨å¯è½ãª heroku-*
â ã¹ã¿ãã¯ã® 1 ã¤ã«åãæ¿ãã¾ãã詳細ã¯ããæ°è¦ã¹ã¿ãã¯ã¸ã®ç§»è¡âããåç
§ãã¦ãã ããã
æ¢ç¥ã®åé¡ã¨å¶éäºé
- ã³ã³ããã¹ã¿ãã¯ã使ç¨ãã¦ããã¢ããªã§ãåºç¤ã¨ãªããã¼ã¹ Docker ã¤ã¡ã¼ã¸ã«å¯¾ããã»ãã¥ãªãã£æ´æ°ããã³ãã°ä¿®æ£ãåå¾ããããã«ã¯ãã¢ããªãåæ§ç¯/åãããã¤ããå¿ è¦ãããã¾ããå¯¾ç §çã«ãHeroku buildpack/slug ãã¼ã¹ã®ãããã¤ã¯ãåºç¤ã¨ãªãã¹ã¿ãã¯ã®ãã¼ã¹ã¤ã¡ã¼ã¸ã¸ã®èªåæ´æ°ãåä¿¡ãããããã¢ããªãåæ§ç¯/åãããã¤ããå¿ è¦ã¯ããã¾ããã
- Heroku ã¯ã
x86_64
â ã¤ã¡ã¼ã¸ã®ã¿ãµãã¼ããã¦ãã¾ããä»ã®ã¢ã¼ããã¯ãã£ã§å®è¡ããããã«æ§ç¯ãããã¤ã¡ã¼ã¸ãã¢ãããã¼ããããã¨ããã¨ãunsupported architecture
â ã¨ã©ã¼ãè¿ããã¾ããã¾ããã³ã³ããã©ã³ã¿ã¤ã 㧠ARM64 ãªã©ã®ä»ã®ã¢ã¼ããã¯ãã£ã使ç¨ãããã¨ããã¨ãExec format
â ã¨ã©ã¼ãçºçãã¾ããã³ã³ãããã«ãã¼ãx86_64
â åã®ã¤ã¡ã¼ã¸ãåºåããããã«ããå¿ è¦ãããã¾ãããã«ããããã¤ã¡ã¼ã¸ã Heroku ç¨ã«æ£ãããã«ãããã¦ãããã¨ã確èªããã«ã¯ãDocker ãã«ãã³ãã³ãã«ãã©ãããã©ã¼ã ãã©ã°ã渡ãã¾ã: âdocker build --platform linux/amd64
âã - Docker ã¤ã¡ã¼ã¸ããã¼ã«ã«ã§ãã«ããã¦ãHeroku Container Registry ã«ããã·ã¥ããã¨ããã¬ãã¥ã¼ã¢ããªã¯ãµãã¼ãããã¾ãããã¬ãã¥ã¼ã¢ããªã§ Docker ã使ç¨ããã«ã¯ãHeroku ã« Docker ã¤ã¡ã¼ã¸ããã«ãã§ããããã«ãã heroku.yml ãããã§ã¹ãâã§ã¢ããªãå®ç¾©ããå¿ è¦ãããã¾ãã
- ãã¤ãã©ã¤ã³ã®ããã¢ã¼ãã¯ãµãã¼ãããã¦ãã¾ããã
- Docker ã¤ã¡ã¼ã¸ã¯ããµã¤ãºã®å¶éã«å¾ãã¾ããã (slugs)â ã¨ç°ãªã)ãdyno èµ·åæéã®å¶éâã«å¾ãã¾ããã¬ã¤ã¤æ°/ã¤ã¡ã¼ã¸ãµã¤ãºã大ãããªãã¨ãdyno èµ·åæéãé·ããªãã¾ãããã®ããã40 ã¬ã¤ã¤ãè¶ ããã¤ã¡ã¼ã¸ã¯ãCommon Runtime ã§ã®èµ·åæã«ã¨ã©ã¼ã«ãªãå¯è½æ§ãããã¾ããDocker ã¤ã¡ã¼ã¸ãµã¤ãºãæ¸ããæ¨å¥¨ã®æ¹æ³ã«ã¤ãã¦ã¯ãDockerfile ã®æ¸ãè¾¼ã¿ã®ãã¹ããã©ã¯ãã£ã¹âã¬ã¤ããåç §ãã¦ãã ããã
- ãã¡ãã®ä¸è¦§âã«è¨è¼ããã¦ãã
Dockerfile
â ã³ãã³ãã¯ãµãã¼ãããã¦ãã¾ããã - Private ã¾ã㯠Shield Space ã®ã³ã³ããã¢ããªã§ã¯ãdyno ãèµ·åããã¨ãã«
.profile
â ã.profile.d/*
â ã¹ã¯ãªãããå®è¡ããã¾ããã - å®è¡æã« Docker ã¤ã¡ã¼ã¸ãæ½åºãããä»çµã¿ãåå ã§ã(以åã® Docker ã¤ã¡ã¼ã¸ã¬ã¤ã¤ã®ãã¡ã¤ã«ãå¾ã®ã¬ã¤ã¤ã¼ã§åé¤ãããã¨ãã«ä½æããã) ãã¯ã¤ãã¢ã¦ããã¡ã¤ã«ã¯åãå
¥ãããã¾ãããCommon Runtime ã§ã®ã¿ã
heroku labs:enable runtime-new-layer-extract
â ã使ç¨ãã¦ãããã解決ããæ°ããæ½åºæ¹æ³ã«åãæ¿ãããã¨ãã§ãã¾ããç¾å¨ãPrivate Space ã§ã®åé¿çã¯ããã¾ããã - åé¿çãé©ç¨âããªãéãã
heroku run
â ã®--exit-code
â å¼æ°ã¯ãµãã¼ãããã¦ãã¾ããã - æ¢åã®ã¢ããªãã³ã³ããã¹ã¿ãã¯ã«ç§»è¡ãã移è¡ã¨åæã«ã¢ããªã®ããã»ã¹åãå¤æ´ããå ´åãæåã§ã¯ãªã¼ã³ã¢ããâããã¾ã§å¤ãããã»ã¹ã® dyno ãæ®ãç¶ããå¯è½æ§ãããã¾ãããããé¿ããã«ã¯ã(移è¡ã¨åæã«ã§ã¯ãªã) ã³ã³ããã¹ã¿ãã¯ã®ç§»è¡ã®åå¾ã«ããã»ã¹åãå¤æ´ãããã移è¡ä¸ã«å¤ãããã»ã¹ãã¹ã±ã¼ã«ãã¦ã³ãã¾ãã
- ã³ã³ããã¹ã¿ãã¯ã使ç¨ãã¦ããã¢ããªã (ãã¼ã«ã«ã§ã¯ãªã) Heroku ã®ãã«ãã·ã¹ãã ã使ç¨ãã¦ãã«ããããå ´åãheroku.yml ã³ã³ãããã«ãã®æ¢ç¥ã®åé¡ã¨å¶éâãé©ç¨ããã¾ãã