Dockerfile
Description
The Dockerfile crawler looks recursively for all Dockerfile from a specific root directory. Then, for each of them, it tries to update each Docker image tag found in a 'FROM' instruction.
Updatecli looks for the following file patterns:
DockerfileDockerfile.*
Override them with the filematch parameter.
The automatic discovery behavior can be tuned by providing a YAML manifest with a dockerfile crawler in top-level directive autodiscovery as explained in the "Autodiscovery" page.
Usage
The dockerfile autodiscovery can use with or without manifest.
Without manifest
Without manifest available, Updatecli will enable all default crawlers, including dockerfile.
updatecli diff to run updatecli in dryrun
updatecli apply to apply the changes locally
With a manifest
If a manifest is provided, Updatecli will only execute crawlers specified in the manifest such as in the following example
updatecli diff --config updatecli.d/default.yamlto run updatecli in dryrunupdatecli apply --config updatecli.d/default.yamlto apply the changes
# updatecli.d/default.yaml
name: "[asciidoctor/docker-asciidoctor] Dockerfile autodiscovery using git scm"
scms:
asciidoctor:
kind: git
spec:
url: https://github.com/asciidoctor/docker-asciidoctor.git
branch: main
autodiscovery:
# scmid is applied to all crawlers
scmid: asciidoctor
crawlers:
dockerfile:
#rootdir: <custom root directory, overriden by scm configuration>
#
## Ignore Dockerfile update matching following rules
#ignore:
# - archs:
# - "amd64"
# path: "qa/*"
# images:
# - alpine
# - alpine:3
#
## Only update Dockerfile matching following rules
#only:
# - archs:
# - "amd64"
# path: "qa/*"
# images:
# - alpine
# - alpine:3
#
# auths:
# Override default dockerfile filematch
#filematch:
# - "Dockerfile.example"
Generated manifests
Each image produces a dockerimage source for the latest tag and a dockerfile target that rewrites the instruction in place. When digest pinning is enabled, a dockerdigest source is added and the digest is written alongside the tag.
digest defaults to true. Set digest: false to track the tag only.
Three details of how FROM instructions are read:
Build arguments are followed. For
ARG GOVERSION=1.21used asFROM golang:${GOVERSION}, the target writes to theARGinstruction rather than theFROMline, so the default stays authoritative.Stage aliases are skipped. A
FROM builder AS finalreferring to an earlier stage is not an external image and yields no manifest.Flags are ignored.
FROM --platform=linux/amd64 alpine:3.18is handled normally.
Authentication
Use auths to reach private registries, keyed by registry URL without a scheme, accepting either a token or a username/password pair. When it is empty Updatecli falls back to the ambient OCI credentials, such as those written by docker login.
Manifest
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| auths | object | “auths” defines the registry credentials, keyed by registry host without scheme. remark:
example: | |
| password | string | “password” defines the container registry password used for authentication. default:
credentials are retrieved from the local environment, such as remark:
| |
| token | string | “token” defines the container registry bearer token used for authentication. default:
credentials are retrieved from the local environment, such as remark:
| |
| username | string | “username” defines the container registry username used for authentication. default:
credentials are retrieved from the local environment, such as remark:
| |
| digest | boolean | “digest” defines whether the generated manifests pin the image digest in addition to the tag. default: true | |
| filematch | array | “filematch” defines the file name patterns used to identify Dockerfiles. default: remark:
| |
| ignore | array | “ignore” defines rules to exclude matching container images from the autodiscovery. remark:
| |
| archs | array | “archs” defines the image architectures to match. remark:
| |
| images | array | “images” defines the container images to match. remark:
| |
| path | string | “path” defines a Dockerfile path pattern. remark:
| |
| only | array | “only” defines rules to restrict the autodiscovery to matching container images. remark:
| |
| archs | array | “archs” defines the image architectures to match. remark:
| |
| images | array | “images” defines the container images to match. remark:
| |
| path | string | “path” defines a Dockerfile path pattern. remark:
| |
| rootdir | string | “rootdir” defines the directory where the crawler starts searching for Dockerfiles. default: the scm directory when “scmid” is set, otherwise the directory relative paths resolve from, by default the working directory. remark:
| |
| versionfilter | object | “versionfilter” defines the version filter used by the generated manifests. default:
kind “semver” with pattern “>= remark:
example: | |
| kind | string | “kind” defines the versioning scheme used to select a version. default: latest remark:
example:
| |
| pattern | string | “pattern” defines the version pattern, according to “kind”. default:
remark:
example:
| |
| regex | string | “regex” defines the regular expression extracting the version from each entry. remark:
example:
| |
| replaceall | object | “replaceall” applies a regular expression replacement to each version before filtering. remark:
example: turns “curl-8_15_0” into “curl-8.15.0”. | |
| pattern | string | “pattern” defines the regular expression matching the text to replace. example:
| |
| replacement | string | “replacement” defines the text replacing each match of “pattern”. remark:
example:
| |
| strict | boolean | “strict” enforces strict semantic versioning rules when parsing versions. default: false remark:
|
Docker Image Tag
The Docker ecosystem has no versioning guidelines. This means that it’s the wild west out there and pretty much impossible to detect all cases. Hence why Updatecli manifest was created.
That being said we are still interested in an autodiscovery feature that would detect as many cases as possible. This section is about documentation what is covered and what’s missing. Do not hesitate to look at the contributing section
Semantic Versioning
In the Docker ecosystem, many tags look like semver but are not.
For instance, node:18.12.1-alpine would match the semver regular expression but the prerelease -alpine is not a prerelease information as per semver convention but a variant of node:18.12.1-buster or node:18.12.1.
This means that we would expect a newer version with the -alpine such as node:19.0.0-alpine.
The dockerfile autodiscovery will handle the following scenarios
1will suggest a version such2otherwise stick to11-alpinewill suggest a version such2-alpineotherwise stick to1-alpine1.0will suggest a version such2.1otherwise stick to1.01.0-alpinewill suggest a version such2.1-alpineotherwise stick to1.0-alpine1.0.0will suggest a version such2.1.0otherwise stick to1.0.01.0.0-alpinewill suggest a version such2.1.0-alpineotherwise stick to1.0.0-alpine
Any other version pattern such as PEP 440 are ignored in the current state. We are planning to add new versionFilter kinds in the future as the need raise.
Feel free to: