Skip to content

Commit 63931e0

Browse files
committed
update build docs
Signed-off-by: Lee Gaines <[email protected]>
1 parent 4e0d928 commit 63931e0

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

docs/apko_file.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ environment:
2525
```
2626
2727
Running `apko build` on this file will produce a tar file containing an Alpine base container image.
28-
The image can be used by container runtimes (for example, running `docker load image.tar` will add
28+
The image can be used by container runtimes (for example, running `docker load < image.tar` will add
2929
the image to Docker). The command `apko publish` can also be used to directly push the image to an
3030
image registry.
3131

docs/build-process.md

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The entire build is configured from a declarative file `apko.yaml`, which does n
55
commands. Instead, all content is generated from installing `apk` packages.
66

77
The build process is driven by the implementation of the `apko build` command, specifically
8-
[`BuildCmd()`](../internal/cli/build.go#L104).
8+
[`BuildCmd()`](../internal/cli/build.go#L142).
99

1010
The entire build process involves laying out the desired files in a temporary working directory, and then
1111
packaging that working directory as an OCI filesystem layer `.tar.gz`. With that layer file in hand,
@@ -14,44 +14,40 @@ it can be packaged into an OCI image, and an SBoM can be created.
1414
The process is as follows:
1515

1616
1. Create a temporary working directory.
17-
1. Create a [`build.Context`](../pkg/build/build.go#L37-45). This `Context` contains:
18-
* The path to the config file, default to `apko.yaml`
19-
* The parsed config file into an internal structure [`ImageConfiguration`](../pkg/build/types/types.go#L55-83)
20-
* The [`buildImplementation`](../pkg/build/build_implementation.go#L43-59), which is the engine responsible for executing the actual build
21-
* The [`Executor`](../pkg/exec/exec.go#L26-31), which handles external command execution by the `buildImplementation`
17+
2. Create a [`build.Context`](../pkg/build/build.go#L52-61). This `Context` contains:
18+
* The parsed config file into an internal structure [`ImageConfiguration`](../pkg/build/types/types.go#L150-199)
2219
* The [`s6.Context`](../pkg/s6/s6.go#L23-26), which contains configuration for optionally installing the s6 supervisor to manage the process in the container
2320
* Build-time options
24-
1. Refresh the `build.Context`, which sets initialization and runtime parameters, such as isolation, working directory, the executor and the s6 context.
25-
1. Build the layer in the working directory, the heart of the build, calling [`build.Context.BuildLayer()`](../pkg/build/build.go#L80-109). This results in the entire laid out filesystem packaged up into a `.tar.gz` file. More detail on this follows later in this document.
26-
1. Generate an SBoM.
27-
1. Generate an OCI image tar file from the single layer `.tar.gz` file in [`oci.BuildImageTarballFromLayer()`](../pkg/build/oci/oci.go#L285).
21+
3. Refresh the `build.Context`, which sets initialization and runtime parameters, such as isolation, working directory, the executor and the s6 context.
22+
4. Build the layer in the working directory, the heart of the build, calling [`build.Context.BuildLayer()`](../pkg/build/build.go#L117-135). This results in the entire laid out filesystem packaged up into a `.tar.gz` file. More detail on this follows later in this document.
23+
5. Generate an SBoM.
24+
6. Generate an OCI image tar file from the single layer `.tar.gz` file in [`oci.BuildImageTarballFromLayer()`](../pkg/build/oci/image.go#L190).
2825

2926
## Layer Build
3027

3128
As described above, after everything is setup, the actual build occurs inside the working directory.
32-
The build is in [`build.Context.BuildLayer()`](../pkg/build/build.go#L80-109), which consists of:
29+
The build is in [`build.Context.BuildLayer()`](../pkg/build/build.go#L117-135), which consists of:
3330

3431
1. `Context.BuildImage()`: building the image
35-
1. `Context.GenerateSBOM()` optionally generate the SBoM
3632

37-
The actual building of the image via `BuildImage()` just wraps [`buildImage()`](../pkg/build/build_implementation.go#L195-247).
33+
The actual building of the image via `BuildImage()` just wraps [`buildImage()`](../pkg/build/build_implementation.go#L154-246).
3834

3935
It involves several steps:
4036

4137
1. Validate the image configuration. This includes setting defaults.
42-
1. Initialize the apk. This involves setting up the various apk directories inside the working directory.
43-
1. Add additional tags for apk packages.
44-
1. `MutateAccounts()`: Create users and groups.
45-
1. Set file and directory permissions.
46-
1. Set the symlinks for busybox, as busybox is a single binary which determines what action to take based on the invoked path.
47-
1. Update ldconfig.
48-
1. Create the `/etc/os-release` file.
49-
1. If s6 is used for supervision, install it and create its configuration files.
38+
2. Initialize the apk. This involves setting up the various apk directories inside the working directory.
39+
3. Add additional tags for apk packages.
40+
4. `MutateAccounts()`: Create users and groups.
41+
5. Set file and directory permissions.
42+
6. Set the symlinks for busybox, as busybox is a single binary which determines what action to take based on the invoked path.
43+
7. Update ldconfig.
44+
8. Create the `/etc/os-release` file.
45+
9. If s6 is used for supervision, install it and create its configuration files.
5046

5147
Note that all of the steps involve some file manipulation.
5248

5349
* In the case of simply laying out files or changing permissions, this is straightforward and performed in the working directory.
54-
* In the case of apk commands, it uses the [pkg/apk/impl](../pkg/apk/impl/) implementation to lay out files directly.
50+
* In the case of apk commands, it uses the [pkg/apk/apk/implementation](../pkg/apk/apk/implementation.go) implementation to lay out files directly.
5551
* In the case of `chown`/`chmod`, if it cannot do so directly - either because the underlying filesystem does not support it or because it is not running as root - it ignores the errors and keeps track of the intended ownership and permissions, adding them to the final layer tar stream.
5652
* In the case of `ldconfig`, it replicates the equivalent functionality by parsing the library ELF headers and creating the symlinks.
5753
* In the case of `busybox`, it creates symlinks to the busybox binary, based on a fixed list.

pkg/build/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import (
4545
)
4646

4747
// Context contains all of the information necessary to build an
48-
// OCI image. Includes the configurationfor the build,
48+
// OCI image. Includes the configuration for the build,
4949
// the path to the config file, the executor for root jails and
5050
// architecture emulation, the s6 supervisor to add to the image,
5151
// build options, and the `buildImplementation`, which handles the actual build.

0 commit comments

Comments
 (0)