File tree Expand file tree Collapse file tree 2 files changed +60
-4
lines changed Expand file tree Collapse file tree 2 files changed +60
-4
lines changed Original file line number Diff line number Diff line change @@ -8,19 +8,47 @@ aliases:
8
8
## Output
9
9
10
10
``` text
11
+ FROM argument 'VARIANT' is not declared
11
12
```
12
13
13
14
## Description
14
15
16
+ This rule warns for cases where you're consuming an undefined build argument in
17
+ ` FROM ` instructions.
18
+
19
+ Interpolating build arguments in ` FROM ` instructions can be a good way to add
20
+ flexibility to your build, and lets you pass arguments that overriding the base
21
+ image of a stage. For example, you might use a build argument to specify the
22
+ image tag:
23
+
24
+ ``` dockerfile
25
+ ARG ALPINE_VERSION=3.20
26
+
27
+ FROM alpine:${ALPINE_VERSION}
28
+ ```
29
+
30
+ This makes it possible to run the build with a different ` alpine ` version by
31
+ specifying a build argument:
32
+
33
+ ``` console
34
+ $ docker buildx build --build-arg ALPINE_VERSION=edge .
35
+ ```
36
+
37
+ This check also tries to detect and warn when a ` FROM ` instruction reference
38
+ miss-spelled built-in build arguments, like ` BUILDPLATFORM ` .
39
+
15
40
## Examples
16
41
17
- ❌ Bad
42
+ ❌ Bad: the ` VARIANT ` build argument is undefined.
18
43
19
44
``` dockerfile
45
+ FROM node:22${VARIANT} AS jsbuilder
20
46
```
21
47
22
- ✅ Good
48
+ ✅ Good: the ` VARIANT ` build argument is defined.
23
49
24
50
``` dockerfile
51
+ ARG VARIANT="-alpine3.20"
52
+ FROM node:22${VARIANT} AS jsbuilder
25
53
```
26
54
Original file line number Diff line number Diff line change 1
1
## Output
2
2
3
3
``` text
4
+ FROM argument 'VARIANT' is not declared
4
5
```
5
6
6
7
## Description
7
8
9
+ This rule warns for cases where you're consuming an undefined build argument in
10
+ ` FROM ` instructions.
11
+
12
+ Interpolating build arguments in ` FROM ` instructions can be a good way to add
13
+ flexibility to your build, and lets you pass arguments that overriding the base
14
+ image of a stage. For example, you might use a build argument to specify the
15
+ image tag:
16
+
17
+ ``` dockerfile
18
+ ARG ALPINE_VERSION=3.20
19
+
20
+ FROM alpine:${ALPINE_VERSION}
21
+ ```
22
+
23
+ This makes it possible to run the build with a different ` alpine ` version by
24
+ specifying a build argument:
25
+
26
+ ``` console
27
+ $ docker buildx build --build-arg ALPINE_VERSION=edge .
28
+ ```
29
+
30
+ This check also tries to detect and warn when a ` FROM ` instruction reference
31
+ miss-spelled built-in build arguments, like ` BUILDPLATFORM ` .
32
+
8
33
## Examples
9
34
10
- ❌ Bad
35
+ ❌ Bad: the ` VARIANT ` build argument is undefined.
11
36
12
37
``` dockerfile
38
+ FROM node:22${VARIANT} AS jsbuilder
13
39
```
14
40
15
- ✅ Good
41
+ ✅ Good: the ` VARIANT ` build argument is defined.
16
42
17
43
``` dockerfile
44
+ ARG VARIANT="-alpine3.20"
45
+ FROM node:22${VARIANT} AS jsbuilder
18
46
```
You can’t perform that action at this time.
0 commit comments