å§ãã«
å
æ¥ã®è¨äºã«ã¦ãFastAPIã®ã¤ã¡ã¼ã¸ã1GBã«ãªã£ã¦ãã¾ã£ã件ãæ¸ãã¾ãããä½ã対çã§ããªããã¨èª¿æ»ãã¦ããä¸ã§ãgzip
ã§ã¯ãªããzstd
ã§å§ç¸®ãããã¨ã§é«ãå§ç¸®çã¨é«ã解åé度ãéæã§ãããã¨ãç¥ãã¾ããã
ä»åã®è¨äºã§ã¯zstd
ã§Dockerã¤ã¡ã¼ã¸ã®å§ç¸®ããã¾ãã
ç°å¢
- Docker Engine
- 27.4.1
- Docker Buildx
- v0.19.3
zstdå§ç¸®ã使ç¨ããããã«ã¯ã次ã®ãã¼ã¸ã§ã³ãå¿ è¦ã§ãã
- Docker Engine
- v24.0.0以é
- Docker Buildx
- 0.8.0以é
# ãã¼ã¸ã§ã³ç¢ºèªç¨ã³ãã³ã docker version docker buildx version
å®è£
確å®ã«ç®çã®ãã¼ã¸ã§ã³ï¼ææ°ãã¼ã¸ã§ã³ï¼ã§ãã«ãããããã«ããã«ãã¼ã¤ã³ã¹ã¿ã³ã¹ãä½æãã¾ãã
次ã«ãdocker buildx
ã®output
ãªãã·ã§ã³ã«å¿
è¦ãªãªãã·ã§ã³ãä»ä¸ããã¨ãzstd
ã§å§ç¸®ã§ãã¾ãã
docker buildx create --name builder --use --platform linux/amd64 docker buildx build --builder builder -t kirimaru/xxx:zstd --output type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true,push=true . # å®éã«ä½¿ç¨ãã¦ããã³ãã³ã # docker buildx build --builder builder --target dev_runtime -t kirimaru/fastapi-practice_dev-runtime:$RUNTIME_TAG --output type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true,push=true .
次ã®ã³ãã³ãã§gzip
ã§å§ç¸®ããã¦ããªããã¨ã確èªãã¾ããã
# gzipã§å§ç¸®ãã¦ããæã®ã¤ã¡ã¼ã¸ docker buildx imagetools inspect --raw kirimaru/fastapi-practice_dev-runtime:python-1c86b7b0d3465cb68c6c3c6e1b256137ef6af039 # 該å½ç®æã®æç² # "mediaType": "application/vnd.docker.image.rootfs.diff.tar.gzip" # zstdã§å§ç¸®ããã¨ãã®ã¤ã¡ã¼ã¸ # â» ãã«ãã¹ãã¼ã¸ãã«ãã ã¨ããããã§ã¹ãã®digestå¤ã¾ã§æå®ããå¿ è¦ãããã¾ã docker buildx imagetools inspect --raw kirimaru/fastapi-practice_dev-runtime:python-97df63af48201968a20c804cdb84e10765e68ee7@sha256:00b9a175bfb82fcd9f3b018e1d726d1a118c7d7357fe0649df1ad73d372222e4 # "mediaType": "application/vnd.oci.image.layer.v1.tar+zstd"
åãªãã·ã§ã³è§£èª¬
--builder builder
ç¹å®ã®ãã«ãã¼ã¤ã³ã¹ã¿ã³ã¹(ä»åã¯builder)ã使ç¨ããã¨ããæå®ã§ãã
-t kirimaru/xxx:zstd
ãã«ãæã®ã¤ã¡ã¼ã¸ã«ã¿ã°ãä»ä¸ãã¾ãã詳細ã¯å¾è¿°ãã¾ãããzstd
ã§å§ç¸®ããéã«ã¯å¿
é ç´ã§ãã
--output ãªãã·ã§ã³
- type=image
- åºåã¿ã¤ããã¤ã¡ã¼ã¸ã¨ãã¦æå®ãã¾ããæå®ã¯å¿ é ã§ã
- oci-mediatypes=true
- OCIï¼Open Container Initiativeï¼ã¡ãã£ã¢ã¿ã¤ãã使ç¨ãã¾ã
- compression=zstd
- Zstandardï¼zstdï¼å§ç¸®ã使ç¨ãã¾ã
- compression-level=3
- zstdå§ç¸®ã®ã¬ãã«ã3ã«è¨å®ãã¾ããï¼1-22ã®ç¯å²ãä½ãã»ã©é«éã§å§ç¸®çã¯ä½ä¸ãã¾ããã3ããã©ã³ã¹ãåãã¦ããããã§ãï¼
- force-compression=true
- æ¢ã«å§ç¸®ããã¦ããã¬ã¤ã¤ã¼ãåå§ç¸®ãã¾ã
- push=true
- ãã«ãå¾ã«ã¤ã¡ã¼ã¸ãã¬ã¸ã¹ããªã«ããã·ã¥ãã¾ã
ããã£ããã¤ã³ã
ãªã¢ã¼ããªãã¸ããªã«ã¤ã¡ã¼ã¸ãpushããéã«zstdã§å§ç¸®ããããã§ããã¼ã«ã«ã§ä¸åº¦ãã«ããã¦ããã¿ã°ãä»ä¸ããªããã¦pushããã¨ãããã¨ã¯ã§ãã¾ããã§ããããã®ããã-t
ã¨push=true
ã§ãã«ãããªããpushãã¦ãã¾ãã
ä»ã®ç´°ãã失æã¯æ¬¡ã«è¨è¼ãã¦ãã¾ãã
- bakeã§ã¯ãã¾ãzstdã§å§ç¸®ã§ããªãã£ã
- ãããããpushãªãã·ã§ã³ãä»ä¸ããã°å¤§ä¸å¤«ã ãããæªæ¤è¨¼
- --type=imagesã ã¨ãã«ããã£ãã·ã¥ã ãã«æ®ãããã§ãã¤ã¡ã¼ã¸åãããªãã£ãããã¨ãã£ã¦ã--loadãä»ä¸ãã¦æ示çã«imageåãããgzipã«ãªã£ã
- --type=dockerã«ããã°åé¡ãªãããã ã£ããããã¡ãã¯gzipã§å§ç¸®ããã
ã½ã¼ã¹ã³ã¼ã
ãªã
çµããã«
ãã¼ã«ã«ã§zstd
ã®æ大å§ç¸®ã¬ãã«ã®22ãæ¤è¨¼ãããã¨ãããã¾ã£ããã¤ã¡ã¼ã¸ãµã¤ãºãå¤ãããªãã¦ãã£ã¨ããã£ã¦ã¾ãããä»ã®ããã°ãåèã«ããã®ã§ãããpush=true
ã«ãã¦ããçç±çãç¹ã«è¨è¼ããªãã£ãã®ã§ãå®å
¨ã«è¦è½ã¨ãã§ãããã