You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: update docs for import types
- reorganize slightly for better readability
- give more examples of valid urls for type 'tar', based on what the
code supports.
- clarify that the type: oci does not require that the url starts with
`oci:`, in fact that will make it fail unless your oci layout is named
`oci`, because in pkg/types/imagesource.go ContainersImageURL() prepends
`oci:` to the url field of type: oci imagesource structs.
Signed-off-by: Michael McCracken <[email protected]>
* feat: reorganize stacker_yaml.md a bit
move the extensive commentary on substitution to the end, it was a bit
much to overexplain that right at the start, my bad.
add a basic common example stacker yaml right at the start so people
know what we are talking about.
Signed-off-by: Michael McCracken <[email protected]>
---------
Signed-off-by: Michael McCracken <[email protected]>
Copy file name to clipboardExpand all lines: doc/stacker_yaml.md
+98-57
Original file line number
Diff line number
Diff line change
@@ -4,55 +4,24 @@ When doing a `stacker build`, the behavior of stacker is specified by the yaml
4
4
directives below.
5
5
6
6
Before the yaml is parsed, stacker performs substitution on placeholders in the
7
-
file of the format `${{VAR}}` or `${{VAR:default}}`. For example, a line like:
8
-
9
-
${{ONE}} ${{TWO:3}}
10
-
11
-
When run with `stacker build --substitute ONE=1` is
12
-
processed in stacker as:
13
-
14
-
1 3
15
-
16
-
In order to avoid conflict with bash or POSIX shells in the `run` section,
17
-
only placeholders with two braces are supported, e.g. `${{FOO}}`.
18
-
Placeholders with a default value like `${{FOO:default}}` will evaluate to their default if not
19
-
specified on the command line or in a substitution file.
20
-
21
-
Using a `${{FOO}}` placeholder without a default will result in an error if
22
-
there is no substitution provided. If you want an empty string in that case, use
23
-
an empty default: `${{FOO:}}`.
24
-
25
-
In order to avoid confusion, it is also an error if a placeholder in the shell
26
-
style (`$FOO` or `${FOO}`) is found when the same key has been provided as a
27
-
substitution either via the command line (e.g. `--substitute FOO=bar`) or in a
28
-
substitution file. An error will be printed that explains how to rewrite it:
29
-
30
-
error "A=B" was provided as a substitution and unsupported placeholder "${A}" was found. Replace "${A}" with "${{A}}" to use the substitution.
31
-
32
-
Substitutions can also be specified in a yaml file given with the argument
33
-
`--substitute-file`, with any number of key: value pairs:
34
-
35
-
FOO: bar
36
-
BAZ: bat
37
-
38
-
In addition to substitutions provided on the command line or a file, the
39
-
following variables are also available with their values from either command
40
-
line flags or stacker-config file.
41
-
42
-
STACKER_STACKER_DIR config name 'stacker_dir', cli flag '--stacker-dir'-
43
-
STACKER_ROOTFS_DIR config name 'rootfs_dir', cli flag '--roots-dir'
44
-
STACKER_OCI_DIR config name 'oci_dir', cli flag '--oci-dir'
45
-
46
-
The stacker build environment will have the following environment variables
47
-
available for reference:
48
-
49
-
*`STACKER_LAYER_NAME`: the name of the layer being built. `STACKER_LAYER_NAME`
50
-
will be `my-build` when the `run` section below is executed.
51
-
52
-
```yaml
53
-
my-build:
54
-
run: echo "Your layer is ${STACKER_LAYER_NAME}"
55
-
```
7
+
file of the format `${{VAR}}` or `${{VAR:default}}`. See [Substitution
8
+
Syntax](#substitution-syntax) at the end of this file for reference.
9
+
10
+
A minimal stacker file has one image definition, with a name and a `from` directive specifying the base image.
11
+
It is most common to have some `imports` and a `run` section to make changes to the base.
12
+
13
+
```yaml
14
+
imagename:
15
+
from:
16
+
type: ...
17
+
url: ...
18
+
imports:
19
+
- some/local/path
20
+
- path: https://some/url
21
+
hash: expected-hash-of-that-url
22
+
run: |
23
+
# shell code to make changes
24
+
```
56
25
57
26
### `from`
58
27
@@ -67,20 +36,36 @@ takes the form:
67
36
68
37
Some directives are irrelevant depending on the type. Supported types are:
69
38
70
-
`docker`: `url` is required, `insecure` is optional. When `insecure` is
71
-
specified, stacker attempts to connect via http instead of https to the Docker
72
-
Hub.
39
+
#### `type: docker`
40
+
41
+
- `url`is required
42
+
43
+
- `insecure`is optional.
44
+
45
+
When `insecure` is specified, stacker attempts to connect via http instead of
46
+
https to the Docker Hub.
47
+
48
+
#### `type: tar`
49
+
50
+
- `url`is required, and can be a local path, an http/https URL, or a stacker url of the format `stacker://$imagename/path/to/tar.gz`
51
+
52
+
#### `type:oci`
73
53
74
-
`tar`:`url` is required, everything else is ignored.
54
+
-`url`is required, and can be a local path to an OCI layout, e.g. `/path/to/layout/image:tag`, or a url pointing to a remote OCI image, e.g. `docker://host/repo/image:tag`
75
55
76
-
`oci`: `url` is required, and must be a local OCI layout URI of the form `oci:/local/path/image:tag`
56
+
#### `type:built`
77
57
78
-
`built`: `tag` is required, everything else is ignored. `built` bases this
79
-
layer on a previously specified layer in the stacker file.
58
+
- `tag`is required, everything else is ignored.
80
59
81
-
`scratch`: the base image is an empty rootfs, and can be used with the `dest` field
60
+
stacker bases this image on another image built in the current session, from the same stacker file or its prerequisites.
61
+
62
+
63
+
#### `type: scratch`:
64
+
65
+
the base image is an empty rootfs, and can be used with the `dest` field
82
66
of `import` to generate minimal images, e.g. for statically built binaries.
83
67
68
+
Note that empty means no shell to run, so unless you import one, `run:` sections will fail for this type.
84
69
85
70
### `imports`
86
71
@@ -298,3 +283,59 @@ defaults to the host operating system if not specified.
298
283
`arch` is a user-specified string value indicating which machine _architecture_ this image is being
299
284
built for, for example, `amd64`, `arm64`, etc. It is an optional field and it
300
285
defaults to the host machine architecture if not specified.
286
+
287
+
### Substitution Syntax
288
+
289
+
Before the yaml is parsed, stacker performs substitution on placeholders in the
290
+
file of the format `${{VAR}}` or `${{VAR:default}}`. See [Substitution
291
+
Syntax](#substitution-syntax) at the end of this document for details.
292
+
293
+
For example, a line like:
294
+
295
+
${{ONE}} ${{TWO:3}}
296
+
297
+
When run with `stacker build --substitute ONE=1` is
298
+
processed in stacker as:
299
+
300
+
1 3
301
+
302
+
In order to avoid conflict with bash or POSIX shells in the `run` section,
303
+
only placeholders with two braces are supported, e.g. `${{FOO}}`.
304
+
Placeholders with a default value like `${{FOO:default}}` will evaluate to their default if not
305
+
specified on the command line or in a substitution file.
306
+
307
+
Using a `${{FOO}}` placeholder without a default will result in an error if
308
+
there is no substitution provided. If you want an empty string in that case, use
309
+
an empty default: `${{FOO:}}`.
310
+
311
+
In order to avoid confusion, it is also an error if a placeholder in the shell
312
+
style (`$FOO` or `${FOO}`) is found when the same key has been provided as a
313
+
substitution either via the command line (e.g. `--substitute FOO=bar`) or in a
314
+
substitution file. An error will be printed that explains how to rewrite it:
315
+
316
+
error "A=B" was provided as a substitution and unsupported placeholder "${A}" was found. Replace "${A}" with "${{A}}" to use the substitution.
317
+
318
+
Substitutions can also be specified in a yaml file given with the argument
319
+
`--substitute-file`, with any number of key: value pairs:
320
+
321
+
FOO: bar
322
+
BAZ: bat
323
+
324
+
In addition to substitutions provided on the command line or a file, the
325
+
following variables are also available with their values from either command
326
+
line flags or stacker-config file.
327
+
328
+
STACKER_STACKER_DIR config name 'stacker_dir', cli flag '--stacker-dir'-
329
+
STACKER_ROOTFS_DIR config name 'rootfs_dir', cli flag '--roots-dir'
330
+
STACKER_OCI_DIR config name 'oci_dir', cli flag '--oci-dir'
331
+
332
+
The stacker build environment will have the following environment variables
333
+
available for reference:
334
+
335
+
* `STACKER_LAYER_NAME`: the name of the layer being built. `STACKER_LAYER_NAME`
336
+
will be `my-build` when the `run` section below is executed.
0 commit comments