-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5003 from dvdksn/doc-UndefinedArgInFrom
lint: add doc for UndefinedArgInFrom
- Loading branch information
Showing
2 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,46 @@ | ||
## Output | ||
|
||
```text | ||
FROM argument 'VARIANT' is not declared | ||
``` | ||
|
||
## Description | ||
|
||
This rule warns for cases where you're consuming an undefined build argument in | ||
`FROM` instructions. | ||
|
||
Interpolating build arguments in `FROM` instructions can be a good way to add | ||
flexibility to your build, and lets you pass arguments that overriding the base | ||
image of a stage. For example, you might use a build argument to specify the | ||
image tag: | ||
|
||
```dockerfile | ||
ARG ALPINE_VERSION=3.20 | ||
|
||
FROM alpine:${ALPINE_VERSION} | ||
``` | ||
|
||
This makes it possible to run the build with a different `alpine` version by | ||
specifying a build argument: | ||
|
||
```console | ||
$ docker buildx build --build-arg ALPINE_VERSION=edge . | ||
``` | ||
|
||
This check also tries to detect and warn when a `FROM` instruction reference | ||
miss-spelled built-in build arguments, like `BUILDPLATFORM`. | ||
|
||
## Examples | ||
|
||
❌ Bad | ||
❌ Bad: the `VARIANT` build argument is undefined. | ||
|
||
```dockerfile | ||
FROM node:22${VARIANT} AS jsbuilder | ||
``` | ||
|
||
✅ Good | ||
✅ Good: the `VARIANT` build argument is defined. | ||
|
||
```dockerfile | ||
ARG VARIANT="-alpine3.20" | ||
FROM node:22${VARIANT} AS jsbuilder | ||
``` |