Skip to content

Commit 76876bb

Browse files
authored
docs: in What's New, clarified custom publishing behavior (#50)
* docs: in What's New, clarified behavior Signed-off-by: mbshields <[email protected]> * docs: Make What's New the first page when Get Started Signed-off-by: mbshields <[email protected]> * docs: updated the substitutions section, etc in the stacker file article Signed-off-by: mbshields <[email protected]> --------- Signed-off-by: mbshields <[email protected]>
1 parent 693aa46 commit 76876bb

File tree

3 files changed

+43
-79
lines changed

3 files changed

+43
-79
lines changed

docs/reference/stacker_file.md

+41-77
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,29 @@ processed in stacker as:
1111

1212
1 2 3
1313

14-
That is, variables of the form `$FOO` or `${FOO}` are supported, and variables
15-
with `${FOO:default}` a default value will evaluate to their default if not
16-
specified on the command line. It is an error to specify a `${FOO}` style
17-
without a default; to make the default an empty string, use `${FOO:}`.
14+
In order to avoid conflict with bash or POSIX shells in the `run` section, only placeholders with two braces are supported, e.g. `${{FOO}}`. Placeholders with a default value like `${{FOO:default}}` will evaluate to their default if not specified on the command line or in a substitution file.
1815

19-
In addition to substitutions provided on the command line, the following
20-
variables are also available with their values from either command
21-
line flags or stacker-config file.
16+
Using a `${{FOO}}` placeholder without a default will result in an error if there is no substitution provided. If you want an empty string in that case, use an empty default: `${{FOO:}}`.
17+
18+
In order to avoid confusion, it is also an error if a placeholder in the shell style (`$FOO` or `${FOO}`) is found when the same key has been provided as a substitution either via the command line (for example, `--substitute FOO=bar`) or in a substitution file. An error will be printed that explains how to rewrite it. For example:
19+
20+
error "A=B" was provided as a substitution and unsupported placeholder "${A}" was found. Replace "${A}" with "${{A}}" to use the substitution.
21+
22+
Substitutions can also be specified in a yaml file given with the argument `--substitute-file`, with any number of key: value pairs:
23+
24+
FOO: bar
25+
BAZ: bat
26+
27+
In addition to substitutions provided on the command line or a file, the following variables are also available with their values from either command line flags or stacker-config file.
2228

2329
STACKER_STACKER_DIR config name 'stacker_dir', cli flag '--stacker-dir'-
2430
STACKER_ROOTFS_DIR config name 'rootfs_dir', cli flag '--roots-dir'
2531
STACKER_OCI_DIR config name 'oci_dir', cli flag '--oci-dir'
2632

27-
2833
The stacker build environment has the following environment variables
2934
available for reference:
3035

31-
* `STACKER_LAYER_NAME`: the name of the layer being built. `STACKER_LAYER_NAME`
32-
will be `my-build` when the `run` section below is executed.
36+
* `STACKER_LAYER_NAME`: the name of the layer being built. `STACKER_LAYER_NAME` will be `my-build` when the `run` section below is executed.
3337

3438
```yaml
3539
my-build:
@@ -38,8 +42,7 @@ available for reference:
3842

3943
### `from`
4044

41-
The `from` directive describes the base image that stacker will start from. It
42-
takes the form:
45+
The `from` directive describes the base image that stacker will start from. It takes the form:
4346

4447
from:
4548
type: $type
@@ -50,16 +53,13 @@ takes the form:
5053
Some directives are irrelevant depending on the type. Supported types are:
5154

5255
`docker`: `url` is required, `insecure` is optional. When `insecure` is
53-
specified, stacker attempts to connect via http instead of https to the Docker
54-
Hub.
56+
specified, stacker attempts to connect via http instead of https to the Docker Hub.
5557

5658
`tar`: `url` is required, everything else is ignored.
5759

58-
`oci`: `url` is required, of the form `path:tag`. This uses the OCI image at
59-
`url` (which may be a local path).
60+
`oci`: `url` is required, and must be a local OCI layout URI of the form `oci:/local/path/image:tag`
6061

61-
`built`: `tag` is required, everything else is ignored. `built` bases this
62-
layer on a previously specified layer in the stacker file.
62+
`built`: `tag` is required, everything else is ignored. `built` bases this layer on a previously specified layer in the stacker file.
6363

6464
`scratch`: which is an empty rootfs and can be used to host statically built binaries.
6565

@@ -73,15 +73,15 @@ Will import a file or directory from the local filesystem. If the file or direct
7373

7474
http://example.com/foo.tar.gz
7575

76-
Will import foo.tar.gz and make it available in `/stacker`. Note that stacker will NOT update this file unless the cache is cleared, to avoid excess network usage. That means that updates after the first time stacker downloads the file will not be reflected.
76+
Will import foo.tar.gz and make it available in `/stacker`. Note that stacker will NOT update this file unless the cache is cleared, to avoid excess network usage. This means that updates after the first time stacker downloads the file will not be reflected.
7777

7878
stacker://$name/path/to/file
7979

8080
Will grab /path/to/file from the previously built image `$name`.
8181

8282
#### `import hash`
8383

84-
Each entry in the `import` directive also supports specifying the hash (sha256sum) of import source, for all the three forms presented above. For example:
84+
Each entry in the `imports` directive also supports specifying the hash (sha256sum) of import source, for all the three forms presented above. For example:
8585
```
8686
imports:
8787
- path: config.json
@@ -91,7 +91,7 @@ imports:
9191
- path: stacker://$name/path/to/file
9292
hash: f805b012017bc769a....
9393
```
94-
Before copying the file, stacker will check that the file's hash matches the given value. For file imports, the source file is hashed at build time. For HTTP imports, the value returned by the server in the `X-Checksum-Sha256` HTTP header is checked first. If that value matches, the file is downloaded and then hashed and compared again.
94+
Before copying or downloading the file, stacker will check that the file's hash matches the given value. For file imports, the source file is hashed at build time. For HTTP imports, the value returned by the server in the `X-Checksum-Sha256` HTTP header is checked first. If that value matches, the file is downloaded and then hashed and compared again.
9595

9696
`stacker build` supports the flag `--require-hash`, which will cause a build error if any HTTP(S) remote imports do not have a hash specified, in all transitively included stacker YAMLs.
9797

@@ -106,9 +106,7 @@ imports:
106106

107107
#### `import dest`
108108

109-
The `import` directive also supports specifying the destination path (specified
110-
by `dest`) in the resulting container image, where the source file (specified
111-
by `path`) will be copyed to. For example:
109+
The `import` directive also supports specifying the destination path (specified by `dest`) in the resulting container image, where the source file (specified by `path`) will be copied to. For example:
112110
```
113111
imports:
114112
- path: config.json
@@ -119,40 +117,31 @@ imports:
119117

120118
The deprecated `import` directive operates like `imports` except that the entries in the `import` array will be placed into `/stacker` instead of `/stacker/imports`.
121119

120+
See https://github.com/project-stacker/stacker/issues/571 for timeline and migration info.
121+
122122
### `overlay_dirs`
123123
This directive works only with OverlayFS backend storage.
124124

125-
The `overlay_dirs` directive describes the directories (content) from the host that should be
126-
available in the container's filesystem. It preserves all file/dirs attributes but no
127-
owner or group.
125+
The `overlay_dirs` directive describes the directories (content) from the host that should be available in the container's filesystem. It preserves all file/dirs attributes but not owner or group.
128126

129127
```
130128
overlay_dirs:
131129
- source: /path/to/directory
132130
dest: /usr/local/ ## optional arg, default is '/'
133131
- source: /path/to/directory2
134132
```
135-
This example will result in all the files/dirs from the host's /path/to/directory
136-
to be available under container's /usr/local/ and all the files/dirs from the host's
137-
/path/to/directory2 to be available under container's /
133+
This example will result in all the files/dirs from the host's /path/to/directory to be available under container's /usr/local/ and all the files/dirs from the host's /path/to/directory2 to be available under container's /
138134

139135

140136
### `environment`, `labels`, `working_dir`, `volumes`, `cmd`, `entrypoint`, `user`
141137

142138
These correspond exactly to the similarly named bits in the [OCI image
143-
config
144-
spec](https://github.com/opencontainers/image-spec/blob/master/config.md#properties),
145-
and are available for users to pass variables through to the runtime environment
146-
of the image.
139+
config spec](https://github.com/opencontainers/image-spec/blob/master/config.md#properties),
140+
and are available for users to pass variables through to the runtime environment of the image.
147141

148142
### `generate_labels`
149143

150-
The `generate_labels` entry is similar to `run` in that it contains a list of
151-
commands to run inside the generated rootfs. It runs after the `run` section is
152-
done, and its mutations to the filesystem are not recorded, except in one case
153-
`/oci-labels`. `/oci-labels` is a special directory where this code can write a
154-
file, and the name of the file will be the OCI label name, and the content will
155-
be the label content.
144+
The `generate_labels` entry is similar to `run` in that it contains a list of commands to run inside the generated rootfs. It runs after the `run` section is done, and its mutations to the filesystem are not recorded, except in one case: `/oci-labels`. `/oci-labels` is a special directory where this code can write a file, and the name of the file will be the OCI label name, and the content will be the label content.
156145

157146
### `build_env` and `build_env_passthrough`
158147

@@ -162,9 +151,7 @@ build environment.
162151
`build_env`: A dictionary of environment variable definitions. The values will be present in the build's environment.
163152

164153
`build_env_passthrough`: A list of regular expressions that work as a
165-
filter on which environment variables should be passed through from the current
166-
env into the container. To let all variables through, simply set
167-
`build_env_passthrough`: `[".*"]`
154+
filter on which environment variables should be passed through from the current env into the container. To let all variables through, simply set `build_env_passthrough`: `[".*"]`
168155

169156
If `build_env_passthrough` is not set, the default behavior is to allow
170157
through proxy variables `HTTP_PROXY, HTTPS_PROXY, FTP_PROXY, http_proxy, https_proxy, ftp_proxy`.
@@ -173,38 +160,27 @@ Values in the `build_env` override values passed through via `build_env_passthro
173160

174161
### `full_command`
175162

176-
Because of the odd behavior of `cmd` and `entrypoint` (and the inherited nature
177-
of these from previous stacker layers), `full_command` provides a way to set
178-
the full command that will be executed in the image, clearing out any previous
179-
`cmd` and `entrypoint` values that were set in the image.
163+
Because of the odd behavior of `cmd` and `entrypoint`, and the inherited nature of these from previous stacker layers, `full_command` provides a way to set the full command that will be executed in the image, clearing out any previous `cmd` and `entrypoint` values that were set in the image.
180164

181165
### `build_only`
182166

183-
`build_only`: indicates whether or not to include this layer in the final OCI
184-
image. This can be useful in conjunction with an import from this layer in
185-
another image, if you want to isolate the build environment for a binary but
186-
not include all of its build dependencies.
167+
`build_only`: indicates whether or not to include this layer in the final OCI image. This can be useful in conjunction with an import from this layer in another image, if you want to isolate the build environment for a binary but not include all of its build dependencies.
187168

188169
### `binds`
189170

190171
`binds`: specifies bind mounts from the host to the container. There are two formats:
191172

192173
binds:
193174
- /foo/bar -> /bar/baz
194-
- /zomg
175+
- /zomg
195176

196-
The first binds /foo/bar to /bar/baz, and the second binds host /zomg to
197-
container /zomg.
177+
The first format binds `/foo/bar` to `/bar/baz`, and the second binds host `/zomg` to container `/zomg`.
198178

199-
At this time there is no awareness of change for any of these bind mounts, so
200-
`--no-cache` should be used to re-build if the content of the bind mount has
201-
changed.
179+
At this time there is no awareness of change for any of these bind mounts, so `--no-cache` should be used to re-build if the content of the bind mount has changed.
202180

203181
### `config`
204182

205-
The `config` key is a special type of entry in the root of the `stacker.yaml` file.
206-
It cannot contain an image definition; it is used to provide configuration
207-
applicable for building all the images defined in this file. For example,
183+
The `config` key is a special type of entry in the root of the `stacker.yaml` file. It cannot contain an image definition; its purpose is to provide configuration applicable for building all the images defined in this file. For example:
208184

209185
config:
210186
prerequisites:
@@ -213,33 +189,21 @@ applicable for building all the images defined in this file. For example,
213189

214190
#### `prerequisites`
215191

216-
If the `prerequisites` list is present under the `config` key, stacker will
217-
make sure to build all the images in the stacker.yaml files found at the paths
218-
contained in the list. In this way, stacker supports building multiple
219-
stacker.yaml files in the correct order.
192+
If the `prerequisites` list is present under the `config` key, stacker will make sure to build all the images in the `stacker.yaml` files found at the paths contained in the list. In this way, stacker supports building multiple `stacker.yaml` files in the correct order.
220193

221-
In this particular case, the parent folder of the current folder, let's call it
222-
`parent`, has 3 subfolders (`folder1`, `folder2`, and `folder3`), each containing a
223-
`stacker.yaml` file. The example `config` above is in `parent/folder1/stacker.yaml`.
194+
In this particular case, the parent folder of the current folder (let's call it `parent`) has 3 subfolders (`folder1`, `folder2`, and `folder3`), each containing a `stacker.yaml` file. The `config` example above is in `parent/folder1/stacker.yaml`.
224195

225-
When `stacker build -f parent/folder1/stacker.yaml` is invoked, stacker searches
226-
for the other two stacker.yaml files and builds them first, before building
227-
the stacker.yaml file specified in the command line.
196+
When `stacker build -f parent/folder1/stacker.yaml` is invoked, stacker searches for the other two `stacker.yaml` files and builds them first before building the `stacker.yaml` file specified in the command line.
228197

229198
#### `annotations`
230199

231-
`annotations` is a user-specified key value map that will be included in the
232-
final OCI image. Note that these annotations are included in the image manifest
233-
itself and not as part of the index.json.
200+
`annotations` is a user-specified key value map that will be included in the final OCI image. Note that these annotations are included in the image manifest itself and not as part of the index.json.
234201

235202
annotations:
236203
a.b.c.key: abc_val
237204
p.q.r.key: pqr_val
238205

239-
While the `config` section supports a similar `labels`, it is more pertinent to the
240-
image runtime. On the other hand, `annotations` is intended to be
241-
image-specific metadata aligned with the
242-
[annotations in the image spec](https://github.com/opencontainers/image-spec/blob/main/annotations.md).
206+
While the `config` section supports a similar `labels`, it is more pertinent to the image runtime. On the other hand, `annotations` is intended to be image-specific metadata aligned with the [annotations in the image spec](https://github.com/opencontainers/image-spec/blob/main/annotations.md).
243207

244208
### os
245209

docs/whats-new.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
### Publish specific images
1212

13-
- By default, the [`stacker publish`](reference/stacker_cli.md#stacker-publish) command pushes all images in a stacker.yaml file instead of only the required images. Using a new command option, `--image <value>`, you can explicitly specify which images are to be published. This command option can be specified multiple times, selecting each image to be included.
13+
- By default, the [`stacker publish`](reference/stacker_cli.md#stacker-publish) command pushes all images in a stacker.yaml file. Using a new command option, `--image <value>`, you can explicitly specify which images are to be published. This command option can be specified multiple times, selecting each image to be included. In either case, images configured with `build-only: true` are not published.
1414

1515
### Specify a single working directory
1616

mkdocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ markdown_extensions:
9898

9999
nav:
100100
- Home: index.md
101+
- What's New: whats-new.md
101102
- Get Started:
102103
- Get Stacker: get_started/get_stacker.md
103104
- Hello Stacker Image: get_started/hello_stacker_image.md
104105
- Stacker Tutorial: get_started/tutorial.md
105106
- Features: features.md
106-
- What's New: whats-new.md
107107
- Concepts:
108108
- About: concepts/about.md
109109
- OCI Image Layout: concepts/oci_image_layout.md

0 commit comments

Comments
 (0)