Docker stacks tagging and manifest creation. This project is inspired on https://github.com/jupyter/docker-stacks.
Project description
Docker stacks tagging and manifest creation
The main purpose of the source code in this folder is to properly tag all the images and to update build manifests. These two processes are closely related, so the source code is widely reused.
Basic example of a tag is a python version tag.
For example, an image jupyter/base-notebook with python 3.8.8 will have a tag jupyter/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 a markdown.
For example, we dump all the conda packages including their versions.
Main principles
- All the images are located in a hierarchical tree. More info on image relationships.
- We have
taggerandmanifestclasses, 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, run
make hook/base-notebook(or another image of your choice).
Source code description
In this section we will briefly describe source code in this folder and give examples on how to use it.
DockerRunner
DockerRunner is a helper class to easily run a docker container and execute commands inside this container:
from .docker_runner import DockerRunner
with DockerRunner("ubuntu:bionic") as container:
DockerRunner.run_simple_command(container, cmd="env", print_result=True)
GitHelper
GitHelper methods are run in the current git repo and give the information about last commit hash and commit message:
from .git_helper import GitHelper
print("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.
Tagger
Tagger is a class, which can be run inside docker container to calculate some tag for an image.
All the taggers are inherited from TaggerInterface:
class TaggerInterface:
"""Common interface for all taggers"""
@staticmethod
def tag_value(container) -> str:
raise NotImplementedError
So, tag_value(container) method gets a docker container as an input and returns some tag.
SHATagger example:
class SHATagger(TaggerInterface):
@staticmethod
def tag_value(container):
return GitHelper.commit_hash_tag()
taggers.pycontains all the taggers.tag_image.pyis a python executable which is used to tag the image.
Manifest
ManifestHeader is a build manifest header.
It contains information about Build datetime, Docker image size and Git commit info.
All the other manifest classes are inherited from ManifestInterface:
class ManifestInterface:
"""Common interface for all manifests"""
@staticmethod
def markdown_piece(container) -> str:
raise NotImplementedError
markdown_piece(container)method returns piece of markdown file to be used as a part of build manifest.
AptPackagesManifest example:
class AptPackagesManifest(ManifestInterface):
@staticmethod
def markdown_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 Hierarchy
All images dependencies on each other and what taggers and manifest they make use of is defined in images_hierarchy.py.
get_taggers_and_manifests.py defines a helper function to get the taggers and manifests for a specific image.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docker-tagging-0.12.1.tar.gz.
File metadata
- Download URL: docker-tagging-0.12.1.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.8.10 Linux/5.11.10-051110-lowlatency
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d88641d142423aaa0c4e9ae661a53f517ce3df249268a225fba45b337753f437
|
|
| MD5 |
176eef6b6a64034aed0d6af5a98a597e
|
|
| BLAKE2b-256 |
e0ec3c5657784345ba5c1d13338a19c7c9847150235dadfb4c8682dde6b7e05a
|
File details
Details for the file docker_tagging-0.12.1-py3-none-any.whl.
File metadata
- Download URL: docker_tagging-0.12.1-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.8.10 Linux/5.11.10-051110-lowlatency
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1687a496f4efee06c5a3f4bbad020c46810fe0914229d24aebb0ab5d747b8933
|
|
| MD5 |
626de748080d78cf546a1a0d59154302
|
|
| BLAKE2b-256 |
04080ef5bfc27ea0a0f085684d341df7c1f9935759cefa126ee498ebd0f135ee
|