canonical / canonical/chisel

Create an official `chisel` container image to improve UX for creating/extending Chiseled base container images

Open
#203 6 comments 7 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
424
Forks
65
Avg merge
12d 19h
Merged PRs (30d)
1

Description

Thanks to the addition of the chisel manifest, we can now use `chisel` to perform multiple subsequent installations of slices on the same rootfs. This is great for creating and extending Chiseled base container images.

However, when creating or extending a Chiseled container image, the UX is not that great since you need to acquire `chisel` before you can create a new rootfs.

Ideally, users wouldn't have to know about `chisel`'s dependencies or need to worry about `golang` versions, etc.
Providing an official Chisel container image would simplify all of this.

## Current UX for acquiring Chisel

### Binary

Extending a container image

```Dockerfile
FROM amd64/ubuntu:noble AS chisel
ARG BASE_IMAGE="ubuntu/dotnet-runtime"
ARG CHISEL_VERSION="v1.X.X"

# Install chisel's dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
file \
&& rm -rf /var/lib/apt/lists/*

# Install chisel
RUN chisel_url=https://github.com/canonical/chisel/releases/download/v${CHISEL_VERSION}/chisel_v${CHISEL_VERSION}_linux_amd64.tar.gz \
&& curl -fSLOJ ${chisel_url} \
&& curl -fSL ${chisel_url}.sha384 | sha384sum -c - \
&& tar -xzf chisel_v${CHISEL_VERSION}_linux_amd64.tar.gz -C /usr/bin/ chisel

# Install new slices
COPY --from=$BASE_IMAGE / /rootfs/
RUN chisel cut --release ubuntu-24.04 --root /rootfs/ \
libicu74_libs \
tzdata-legacy_zoneinfo \
tzdata_zoneinfo

FROM scratch AS final
COPY --link --from=chisel /rootfs /
```

### Golang

Extending a container image

```Dockerfile
FROM amd64/golang:1.2X AS chisel
ARG BASE_IMAGE="ubuntu/dotnet-runtime"
ARG CHISEL_VERSION="v1.X.X"

# Install chisel's dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
file \
&& rm -rf /var/lib/apt/lists/*

# Install chisel tool
RUN go install github.com/canonical/chisel/cmd/chisel@v${CHISEL_VERSION}

# Install new slices
COPY --from=$BASE_IMAGE / /rootfs/
RUN chisel cut --release ubuntu-24.04 --root /rootfs/ \
libicu74_libs \
tzdata-legacy_zoneinfo \
tzdata_zoneinfo

FROM scratch AS final
COPY --link --from=chisel /rootfs /
```

## Desired UX

### Creating a base image

```Dockerfile
FROM amd64/ubuntu/chisel:v1.X.X AS chisel

# Install slices
RUN mkdir -p /rootfs \
&& chisel cut --release ubuntu-24.04 --root /rootfs \
base-files_base \
base-files_chisel \
base-files_release-info \
...

FROM scratch AS final
COPY --link --from=chisel /rootfs /
```

### Extending a base image

```Dockerfile
FROM amd64/ubuntu/chisel:v1.X.X AS chisel
ARG BASE_IMAGE="ubuntu/dotnet-runtime"

# Install new slices
COPY --from=$BASE_IMAGE / /rootfs/
RUN chisel cut --release ubuntu-24.04 --root /rootfs/ \
libicu74_libs \
tzdata-legacy_zoneinfo \
tzdata_zoneinfo

FROM scratch AS final
COPY --link --from=chisel /rootfs /
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.