UX: Running `chisel cut` with slices as single arg? (or sourced from a file arg)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Bắt đầu bằng việc xem xét entry point của CLI chisel cut và các ví dụ SHELL và RUN trong Dockerfile được mô tả ở đây. So sánh cách phân tích slice bằng một đối số duy nhất được đề xuất, các dấu phân cách và các phương án thay thế bằng tệp cấu hình, sau đó xác định hành vi và các bài kiểm thử trong một phạm vi được giới hạn; việc hoàn tất cần bao gồm một cách được lập tài liệu và kiểm thử để cung cấp các slice mà không cần các đối số CLI riêng biệt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
TL;DR: Instead of providing slices via a list of args, there are some scenarios where a single arg is more convenient, be that a string of slices or a file config.
When experimenting with chisel, I noticed that I could technically set:
# NOTE: `SHELL` is not an OCI spec compatible instruction,
# thus won't work by default with Podman or other alternatives to Docker.
SHELL ["/chisel", "cut", "--release", "ubuntu-24.04", "--root", "/"]
And then a RUN instruction would only be the slices. However that is presently only compatible in the JSON RUN syntax since each slice is expected as a separate arg:
# JSON syntax (separate args):
RUN ["base-files_base", "bash_bins"]
# SHELL syntax (string):
RUN base-files_base bash_bins
# Equivalent to JSON syntax:
RUN ["base-files_base bash_bins"]
This fails as chisel will see that as a single slice (although I don't think spaces would be valid in a slice name?). Perhaps with a single arg for the slices it could split that into the actual slices? Or a delimiter like , could be supported?
Another option would be to source the slices via a separate config file instead of as CLI args?
- This file could contain other CLI args such as the release channel, install root, and opt-in/out of Ubuntu Pro, etc.
- It could also technically group slices by their suffix, such as a list of slices under
base:likebase-files, andbins:likebash, which might be nicer/practical than the repetitive slice suffixes?
I thought this concern was worth seeking some feedback on, as it might be nice to support running chisel without requiring a shell as demonstrated below in the reference section.
When I initially opened this report I had a misunderstanding that I couldn't use a shell for --root / on FROM scratch, requiring instead --root /root-fs (and the creation of that location, plus another stage in the build to copy from /root-fs to /). That was a user error on my part as I had mounted Nushell to /bin/nu instead of /usr/bin/local/nu.
Reference
Base image to use chisel from
Ideally in future there would be an official chisel image instead of extra steps to acquire the binary to run chisel:
FROM alpine AS chisel
ARG CHISEL_VERSION=1.1.0
ARG TARGETARCH
ARG CHISEL_RELEASE="https://github.com/canonical/chisel/releases/download/v${CHISEL_VERSION}/chisel_v${CHISEL_VERSION}_linux_${TARGETARCH}.tar.gz"
# NOTE: `--no-same-owner` used as `chisel` release has ownership of `1001:128`
RUN wget -qO - "${CHISEL_RELEASE}" | tar -xz --no-same-owner -C /usr/local/bin chisel
FROM scratch + Shell
Here's one way to then run with chisel on a scratch base (this is ok, the issue was originally created before I realized this approach also worked with --root /):
FROM scratch
ENV XDG_CACHE_HOME=/cache
SHELL ["/usr/local/bin/nu", "-c"]
RUN --mount=type=cache,target=${XDG_CACHE_HOME}/chisel,id="chisel-cache" \
--mount=type=bind,from=chisel,source=/etc/ssl/certs/ca-certificates.crt,target=/etc/ssl/certs/ca-certificates.crt \
--mount=type=bind,from=chisel,source=/usr/local/bin/chisel,target=/chisel \
--mount=type=bind,from=ghcr.io/nushell/nushell,source=/usr/bin/nu,target=/usr/local/bin/nu \
/chisel cut --release ubuntu-24.04 --root / \
base-files_base bash_bins procps_bins grep_bins gawk_bins sed_bins coreutils_bins busybox_bins openssl_bins curl_bins
NOTES:
/etc/ssl/certs/ca-certificates.crt(or similar) is required.- This location is not configurable like some other tools (eg:
curl) offer, perhaps it should be? (or better,chiselcould embed a fallback? This file is about 220KB on Alpine) - If this
ca-certificates.crtfile would be modified bychiseldue to slices installed, a bind mount here is probably not appropriate, you'd need an earlierCOPYinstead and lose some image weight efficiency (fallback or alternative path would avoid this concern).
- This location is not configurable like some other tools (eg:
- Nushell has been used as the shell instead of
bash, only because this easily allows for a shell that works onscratchas it's a single self-contained binary likechisel.- While Nushell could use additional commands, note that
\cannot be used for multi-line splitting (valid for bash) if providingRUNa HereDoc string (multi-line input, akin to an actual script, which then encodes the\as part of that string, not as part of theRUNinstruction itself that is parsed). Hence additional commands in the sameRUNrequire familiarity with Nushell's syntax differences from Bash (&&=>;,\=>(...)).
- While Nushell could use additional commands, note that
- If not using
--root /withscratch,WORKDIR /root-fs+--root /root-fsor similar would be required aschiseldoes not yet create the--rootlocation when it doesn't exist. A separate stage to then copy/root-fsto/would be required aschiselmay fail when existing base image conflicts (such as an existing/binthat would otherwise be symlinked to/usr/bin).
FROM scratch without a shell
Alternatively, a shell can be avoided by using the RUN JSON syntax (tad awkward, but avoids running via defined SHELL):
FROM scratch
ENV XDG_CACHE_HOME=/cache
RUN --mount=type=cache,target=${XDG_CACHE_HOME}/chisel,id="chisel-cache" \
--mount=type=bind,from=chisel,source=/etc/ssl/certs/ca-certificates.crt,target=/etc/ssl/certs/ca-certificates.crt \
--mount=type=bind,from=chisel,source=/usr/local/bin/chisel,target=/chisel \
[ \
"/chisel", "cut", "--release", "ubuntu-24.04", "--root", "/", \
"base-files_base", "bash_bins", "procps_bins", "grep_bins", "gawk_bins", "sed_bins", "coreutils_bins", "busybox_bins", "openssl_bins", "curl_bins" \
]
FROM scratch with shell provided by earlier chisel RUN
You could also use a mix of the two to first get a shell provisioned, then install the rest of the slices:
FROM scratch
ENV XDG_CACHE_HOME=/cache
# Required for default `SHELL ["/bin/sh", "-c"]`
# Provision `/bin/sh` (`base-files_base` creates `/bin` -> `/usr/bin` symlink, `dash_bins` creates `/usr/bin/sh` -> `/usr/bin/dash` symlink)
# Alternatively use `bash_bins` and then set `SHELL ["/usr/bin/bash", "-c"]` or create a `/bin/sh` -> `/usr/bin/bash` symlink (requires `coreutils_bins` for `ln`)
RUN --mount=type=cache,target=${XDG_CACHE_HOME}/chisel,id="chisel-cache" \
--mount=type=bind,from=chisel,source=/etc/ssl/certs/ca-certificates.crt,target=/etc/ssl/certs/ca-certificates.crt \
--mount=type=bind,from=chisel,source=/usr/local/bin/chisel,target=/chisel \
[ "/chisel", "cut", "--release", "ubuntu-24.04", "--root", "/", "base-files_base", "dash_bins"]
# Now you can use `SHELL` syntax `RUN`:
RUN --mount=type=cache,target=${XDG_CACHE_HOME}/chisel,id="chisel-cache" \
--mount=type=bind,from=chisel,source=/etc/ssl/certs/ca-certificates.crt,target=/etc/ssl/certs/ca-certificates.crt \
--mount=type=bind,from=chisel,source=/usr/local/bin/chisel,target=/chisel \
/chisel cut --release ubuntu-24.04 --root / base-files_base bash_bins procps_bins grep_bins gawk_bins sed_bins coreutils_bins busybox_bins openssl_bins curl_bins
NOTE: The 2nd RUN presently incurs layer inefficiency with chisel installing existing slices, about 5MB wasted in this example (48MB image instead of 43MB). This should be resolved in a future release.
- Ngôn ngữ chính
- Go
- Star
- 434
- Fork
- 74
- Merge trung bình
- 1 ngày 30 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của canonical/chisel
-
`mode` of a generated directory is random when it has a generated childCó thể đã có người làm @Amadeus-22 đã nhận 24 ngày trước. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
-
cut fails on uncompressed debCó thể đã có người làm @yuminn-k đã nhận 29 ngày trước. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 42/100
-
`prefer` drops a path when the preferred package lists it `until: mutate`Có thể đã có người làm @18Abhinav07 đã nhận 8 ngày trước. Đang mởBug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
Tất cả issue của canonical/chisel
Issue tương tự
-
mcpx scan: flag unsafe tool namesCó thể đã có người làm @zeyadbadawyy đã nhận hôm nay. Đang mởarea/scan enhancement good first issue priority/medium size/small
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
rohitgollarahalli/mcpx#45 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Mend: dependency security vulnerability
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Windows 主机
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Lee-xeo/Claude-Cage#1550 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
(bug) ui: spanPaint can index spans past their end (panic: index out of range)Có thể đã có người làm @MaxMiksa đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
Maintainer thường phản hồi trong vòng 1 ngày