Skip to main content

dockerfile_from_ref

Function dockerfile_from_ref 

Source
pub fn dockerfile_from_ref(dockerfile: &str) -> Option<&str>
Expand description

The image ref in a Dockerfile’s first FROM, or None when it has none.

Deliberately loose on whitespace and case, and it ignores --platform= and AS name decoration, because the check exists to catch a base that disagrees rather than to validate Dockerfile syntax.

Split-and-scan rather than a regex: the pattern is “first token after FROM on a line whose first word is FROM”, which split_whitespace states more directly than a pattern string would. (regex-lite is available if this ever grows.)