Open1

Chisel

とりいとりい

概要

https://github.com/canonical/chisel

参考

https://www.youtube.com/live/byPpJW5l6pg?si=PacaC95eXomNf7Tx&t=7137

  • Re-inventing distroless with Chiselled Ubuntu containers

  • 環境:Ubuntu 22.04

インストール

sudo snap install chisel

デモ

chisel find --release ubuntu-24.04 node*
chisel info --release ubuntu-24.04 nodejs_bins nodejs_copyright

Ubuntu24.04 パッケージからnodejsを切り出す

mkdir rootfs
chisel cut --release ubuntu-24.04 --root rootfs nodejs_bins base-files_chisel
sudo chroot rootfs nodejs -v
sudo chroot rootfs nodejs -e "console.log('Hello')"

切り出し時に生成されたmanifestの確認

ll rootfs/var/lib/chisel/manifest.wall
file rootfs/var/lib/chisel/manifest.wall
zstd -d -c rootfs/var/lib/chisel/manifest.wall | jq
zstd -d -c rootfs/var/lib/chisel/manifest.wall | jq -r 'select(.kind=="package") | "\(.name), \(.version)"'

コンテナのビルド

dockerfile
FROM scratch

COPY rootfs /

ENTRYPOINT ["node"]
docker build -t node:chiselled .
docker images node
docker run -it --rm node:chiselled