Skip to content

Commit c60ee1a

Browse files
cjdcordeiroRafid Bin MostofaletFunny
authored
docs: bootstrap chisel docs (canonical#4)
--------- Co-authored-by: Yana Hontyk Co-authored-by: Rafid Bin Mostofa <rafid.mostofa@canonical.com> Co-authored-by: Alberto Carretero <angelalbertoc.r@gmail.com>
1 parent 9bb549e commit c60ee1a

26 files changed

+1783
-2
lines changed

docs/.custom_wordlist.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
AGPL
2+
Armored
3+
Levenshtein
4+
OpenPGP
5+
Starlark
6+
Subcommands
7+
ZSTD
8+
armor
9+
armored
10+
basename
11+
esm
12+
fips
13+
http
14+
https
15+
jsonwall
16+
optimize
17+
subcommand
18+
subcommands
19+
symlink
20+
ubuntu
21+
yaml

docs/_static/MO-1.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/_static/MO-2.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/_static/MO-3.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/_static/MO-4.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/_static/package-slices.svg

Lines changed: 66 additions & 0 deletions
Loading

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
#
119119
# NOTE: If set, adding ':discourse: 123' to an .rst file
120120
# will add a link to Discourse topic 123 at the bottom of the page.
121-
"discourse": "https://discourse.ubuntu.com",
121+
"discourse": "https://discourse.ubuntu.com/tags/c/rocks/117/chisel",
122122
# Your Mattermost channel URL
123123
#
124124
# TODO: Change to your Mattermost channel URL or leave empty.

docs/explanation/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Explanation
2+
3+
This section of the documentation covers the core concepts of Chisel.
4+
5+
```{toctree}
6+
:maxdepth: 1
7+
8+
mode-of-operation
9+
slices
10+
```
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
(chisel_mo_explanation)=
2+
# How Chisel works
3+
4+
The purpose of Chisel is to create a minimal Ubuntu root file system comprising
5+
only the application and its runtime dependencies. Chisel is especially useful
6+
for developers who are looking to create minimal and distroless-like container
7+
images.
8+
9+
Chisel uses the {{cut_cmd}} to _slice_ Ubuntu packages, as depicted in the workflow below:
10+
11+
<table style="width: 100%;">
12+
<colgroup>
13+
<col style="width: 45%;">
14+
<col style="width: 55%;">
15+
</colgroup>
16+
17+
<!-- MO 1 -->
18+
<tr>
19+
<td>
20+
21+
```{image} /_static/MO-1.svg
22+
:align: center
23+
:alt: Read and parse chisel-releases
24+
```
25+
26+
</td>
27+
<td>
28+
29+
Chisel fetches, reads and validates the {ref}`chisel-release<chisel-releases_ref>`.
30+
This includes parsing the {ref}`chisel_yaml_ref` and {ref}`slice
31+
definitions<slice_definitions_ref>` while validating the release and checking for conflicting paths across packages.
32+
33+
</td>
34+
</tr>
35+
36+
37+
<!-- MO 2 -->
38+
<tr>
39+
<td>
40+
41+
```{image} /_static/MO-2.svg
42+
:align: center
43+
:alt: Talk to archives and fetch packages
44+
```
45+
46+
</td>
47+
<td>
48+
49+
Chisel talks to the {ref}`chisel_yaml_format_spec_archives` directly.
50+
It fetches, validates and parses their `InRelease` files.
51+
It then resolves which archive holds the **requested** packages and fetches
52+
the corresponding package tarballs.
53+
54+
</td>
55+
</tr>
56+
57+
<!-- MO 3 -->
58+
<tr>
59+
<td>
60+
61+
```{image} /_static/MO-3.svg
62+
:align: center
63+
:alt: Install package slices
64+
```
65+
66+
</td>
67+
<td>
68+
69+
Chisel groups and merges all slice definitions per package. Then,
70+
for every package, it extracts the **specified slices' paths** into
71+
the provided root file system.
72+
73+
</td>
74+
</tr>
75+
76+
<!-- MO 4 -->
77+
<tr>
78+
<td>
79+
80+
```{image} /_static/MO-4.svg
81+
:align: center
82+
:alt: Run mutation scripts
83+
```
84+
85+
</td>
86+
<td>
87+
88+
Chisel then runs the {{mutation_scripts}}. Only the
89+
{ref}`mutable<slice_definitions_format_slices_contents_mutable>` files may be
90+
modified at this stage. Finally, the files specified with
91+
{ref}`until:mutate<slice_definitions_format_slices_contents_until>` are
92+
removed from the provided root file system.
93+
94+
95+
</td>
96+
</tr>
97+
</table>

docs/explanation/slices.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
(slices_explanation)=
2+
# Slices
3+
4+
## What are package slices?
5+
6+
Since Debian packages are simply archives that can be inspected, navigated and
7+
deconstructed, it is possible to define slices of packages that contain
8+
minimal, complementary, loosely-coupled sets of files based on package metadata
9+
and content. Such **package slices** are subsets of Debian packages, with their
10+
own content and set of dependencies to other internal and external slices.
11+
12+
The use of package slices provides the ability to build minimal root file
13+
system from the wider set of Ubuntu packages.
14+
15+
```{image} /_static/package-slices.svg
16+
:align: center
17+
:width: 75%
18+
:alt: Debian package slices with dependencies
19+
```
20+
21+
This image illustrates the simple case where, at a package level, package _B_
22+
depends on package _A_. However, there might be files in _A_ that _B_ doesn't
23+
actually need, but which are provided for convenience or completeness. By
24+
identifying the files in _A_ that are actually needed by _B_, we can divide _A_
25+
into slices that serve this purpose. In this example, the files in the package
26+
slice, _A_slice3_, are not needed for _B_ to function. To make package _B_
27+
usable in the same way, it can also be divided into slices.
28+
29+
With these slice definitions in place, Chisel is able to extract a
30+
highly-customised and specialised slice of the Ubuntu distribution, which one
31+
could see as a block of stone from which we can carve and extract only the
32+
small and relevant parts that we need to run our applications, thus keeping the
33+
file system small and less exposed to vulnerabilities.
34+
35+
## Defining slices
36+
37+
A package's slices can be defined via a YAML slice definitions file. Check
38+
{ref}`slice_definitions_ref` for more information about this file's format.
39+
40+
## Naming convention
41+
42+
In Chisel, slices are recognized by the following pattern:
43+
`<package_name>_<slice_name>`.
44+
45+
For example, the slice `libc6_libs` refers to the slice definition `libs` of the
46+
package `libc6`.
47+
48+
49+
The use of an underscore in this pattern is what distinguishes package names from
50+
slice names, as this character is not allowed in Debian package names.

0 commit comments

Comments
 (0)