Package: docker-tagging
Docker stacks tagging and manifest creationThe main purpose of the source code in this folder is to properly tag all the images and to updatebuild manifests.
These two processes are closely related, so the source code is widely reused.Basic example of a tag is apythonversion tag.
For example, an imagejupyter/base-notebookwithpython 3.8.8will have a tagjupyter/base-notebook:python-3.8.8.
This tag (and all the other tags) are pushed to Docker Hub.Manifest is a description of some important part of the image in amarkdown.
For example, we dump all thecondapackages including their versions.Main principlesAll the images are located in a hierarchical tree. More info onimage relationships.We havetaggerandmanifestclasses, which can be run inside docker containers to obtain tags and build manifest pieces.These classes are inherited from the parent image to all the children images.Because manifests and tags might change from parent to children,taggersandmanifestsare reevaluated on each image. So, the values are not inherited.To tag an image and create a manifest, runmake hook/base-notebook(or another image of your choice).Source code descriptionIn this section we will briefly describe source code in this folder and give examples on how to use it.DockerRunnerDockerRunneris a helper class to easily run a docker container and execute commands inside this container:from.docker_runnerimportDockerRunnerwithDockerRunner("ubuntu:bionic")ascontainer:DockerRunner.run_simple_command(container,cmd="env",print_result=True)GitHelperGitHelpermethods are run in the currentgitrepo and give the information about last commit hash and commit message:from.git_helperimportGitHelperprint("Git hash:",GitHelper.commit_hash())print("Git message:",GitHelper.commit_message())Prefix of commit hash (namely, 12 letters) is used as an image tag to make it easy to inherit from a fixed version of a docker image.TaggerTaggeris a class, which can be run inside docker container to calculate some tag for an image.All the taggers are inherited fromTaggerInterface:classTaggerInterface:"""Common interface for all taggers"""@staticmethoddeftag_value(container)->str:raiseNotImplementedErrorSo,tag_value(container)method gets a docker container as an input and returns some tag.SHATaggerexample:classSHATagger(TaggerInterface):@staticmethoddeftag_value(container):returnGitHelper.commit_hash_tag()taggers.pycontains all the taggers.tag_image.pyis a python executable which is used to tag the image.ManifestManifestHeaderis a build manifest header.
It contains information aboutBuild datetime,Docker image sizeandGit commitinfo.All the other manifest classes are inherited fromManifestInterface:classManifestInterface:"""Common interface for all manifests"""@staticmethoddefmarkdown_piece(container)->str:raiseNotImplementedErrormarkdown_piece(container)method returns piece of markdown file to be used as a part of build manifest.AptPackagesManifestexample:classAptPackagesManifest(ManifestInterface):@staticmethoddefmarkdown_piece(container)->str:return"\n".join(["## Apt Packages","",quoted_output(container,"apt list --installed")])quoted_outputsimply runs the command inside container usingDockerRunner.run_simple_commandand wraps it to triple quotes to create a valid markdown piece of file.manifests.pycontains all the manifests.create_manifests.pyis a python executable which is used to create the build manifest for an image.Images HierarchyAll images dependencies on each other and what taggers and manifest they make use of is defined inimages_hierarchy.py.get_taggers_and_manifests.pydefines a helper function to get the taggers and manifests for a specific image.