OCI tagging strategy
Foreword
Image builders that comply with the Open Container Image (OCI) standard, such as Docker, Kaniko or BuildKit, can apply a list of tags to the image at the end of the build. If no tag is provided, the latest tag is applied automatically.
Recommendations
The tagging strategy below provides satisfactory traceability for tracking and auditing deliveries, and clearly identifies the target runtime environment (local, test, production).
Tag latest
The most recent image. Use only for local development, unit testing or integration testing.
Security/DICT: none Usability: high
Tag <runtime | os version>
Name and version of the runtime that executes the application process (e.g. python310).
If the application is a binary, give the name and version, or the name of the operating system distribution (e.g. 20.04, focal, centos8).
Security/DICT: low Usability: medium
Tag x.x.x
Application version following the SemVer standard (e.g. 0.0.1).
Security/DICT: medium Usability: medium
A suffix can target the environment (e.g. 0.0.1-beta1):
-alpha1: development-beta1: integration-rc1: user acceptance / pre-production- no suffix: production
Tag x.x.x-<runtime | os version>
Application version and the associated runtime (e.g. 0.0.1-python310).
Recommended for the production environment.
Security/DICT: high Usability: medium
Tag x.x.x-<runtime | os version>-<git short hash>
Application version and the associated runtime, enriched with the git commit used during the build, which makes it possible to trace changes in the code base (e.g. 0.0.1-python310-a12b3c4d).
Security/DICT: very high Usability: very low
Run the following command in the repository directory to generate the git short hash.
GIT_SHORT_HASH="$(git rev-parse --short=8 HEAD)"