Skip to main content

determine-docker-tags

A python program used to determine which docker tags should be applied to a docker image.

Installation

There is a ready-to-go docker image on Docker Hub.

You can also find it on PyPi and it can easily be installed with:

pip install determine-docker-tags

Options

Here is a list of the options available. You can find more detailed usage instructions below.

ENV Var Default Description
VERSION_TYPE "" How the program should find the version number. Can be "docker_env", "docker_from", "date", "string" or "".
STRING_VERSION "" The version string to process when VERSION_TYPE is set to "string"
IMAGE_NAME "" The name of the docker image.
APP_NAME "" The name of the application whose version number you want to use to generate tags.
DOCKERFILE_PATH "Dockerfile" The path to the Dockerfile you want to run the program on
APP_ENV "" A static string to add to the end of every tag with a "-" added inbetween the tag and the string. The string will not be added to any tags defined in CUSTOM_TAGS.
CUSTOM_TAGS "" Any extra static tags you want to add to the image, for example "latest". You can provide a list in the form of a comma separated string to specify multiple tags. For example "latest,prod,example"
INCLUDE_MAJOR "yes" If the major version number should be a tag. This setting will be ignored if the major version number is 0. Can be "yes" or "no".
INCLUDE_SUFFIX "yes" If the suffix that you find after the version number in many docker image tags should be kept and added to every tag. Can be "yes" or "no"
VERSION_PASSTHROUGH "no" If you want the string to be directly used as is, without any further processing. Applies to VERSION_TYPE "docker_env", "docker_from" and "string"

Usage

The program is configured through environment variables. The program automatically figures out the version numbers to use as tags from a Dockerfile. The tags are written to FORGEJO_OUTPUT if it is set, otherwise to GITHUB_OUTPUT if it is set, otherwise to .tags in the current workspace.

Version type

To use the program you first need to figure out which VERSION_TYPE you want to use. There are five options to choose from. The default or an empty string requires CUSTOM_TAGS to be set and just creates a .tags file with the contents of CUSTOM_TAGS.

date

If VERSION_TYPE is set to date a tag will be created corresponding to the current date in format YEARMONTHDAY for example 20210101. If APP_ENV is set it will currently be ignored using this VERSION_TYPE.

string

If VERSION_TYPE is set to string then the version string set in STRING_VERSION will be used to create the tags in the same way as the docker_env and docker_from version types.

docker_env

If VERSION_TYPE is set to docker_env then APP_NAME is also required. When docker_env is used the program looks for the APP_NAME version number set as an ENV var in the Dockerfile. The required formating to use in the Dockerfile is:

ENV APP_NAME_VERSION VERSION_NUMBER

So lets say the "APP_NAME" we are looking for is Nginx, then we would set "APP_NAME" to "NGINX" and the ENV var in the Dockerfile would look like this:

ENV NGINX_VERSION 1.18.0

This would generate the following tags:

1,1.18,1.18.0

docker_from

If VERSION_TYPE is set to docker_from then APP_NAME is also required. When using this VERSION_TYPE the version number is taken from a FROM instruction in the provided Dockerfile. Let's say we had the following FROM instruction in our Dockerfile:

FROM nginx:1.18.0

We then set APP_NAME to nginx and the generated tags would be:

1,1.18,1.18.0

APP ENV

APP_ENV is a static string that will be added to the end of dynamically created tag, so not the ones defined in CUSTOM_TAGS. A - is added between the generated tag and the contents of APP_ENV. Let's say we had the version number 1.18.0 and APP_ENV was set to prod then we would get the following tags:

1-prod,1.18-prod,1.18.0-prod

INCLUDE_MAJOR

INCLUDE_MAJOR determine whether the major version number should have a tag of its own. The default for this option is yes If the major version number is 0 this option will be ignored and a tag with only the major version number won't be created. Let's say we had the version number 1.18.0 and INCLUDE_MAJOR is set to no then we would get the following tags:

1.18,1.18.0

INCLUDE_SUFFIX

INCLUDE_SUFFIX is mainly intended to be used with the docker_from version type. It determines whether the suffix should be included in the generated tags. The default for this option is yes. Let's say we had the following FROM instruction in our Dockerfile:

FROM nginx:1.18.0-alpine

With the default of yes that would generated the following tags:

1-alpine,1.18-alpine,1.18.0-alpine

And if set to no the following tags would be generated:

1,1.18,1.18.0

License

This program is licensed under the EUPL-v1.2.

Metadata

Release files for determine-docker-tags 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for determine-docker-tags 0.4.1
File Size Uploaded Provenance Actions
determine_docker_tags-0.4.1.tar.gz 8.6 kB Without provenance Details for determine_docker_tags-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for determine-docker-tags 0.4.1
File Interpreter ABI Platform Actions
determine_docker_tags-0.4.1-py3-none-any.whl Python 3 none any Details for determine_docker_tags-0.4.1-py3-none-any.whl

Total release size: 18.4 kB

Release files / determine_docker_tags-0.4.1.tar.gz

Download URL determine_docker_tags-0.4.1.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
da062221c88451728a38ec955a3e0cbc8d7d791499dd5d148ea558656f742c67
BLAKE2b-256 checksum
How to use checksums
ed7c3f3950112ca6cc6be948c36620050cb3370854ba64f1427825f7e2f57a69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.4 CPython/3.13.5 Linux/6.12.85+deb13-cloud-amd64

Release files / determine_docker_tags-0.4.1-py3-none-any.whl

Download URL determine_docker_tags-0.4.1-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f54ff39be36d74b67669619ba095069ec33c147adf56db857ec6833e90b1758a
BLAKE2b-256 checksum
How to use checksums
54df5d2a62be721a686200e77d158f76469d459f5a4431f45fe0318a70bc4fcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.4 CPython/3.13.5 Linux/6.12.85+deb13-cloud-amd64

Security for determine-docker-tags 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page