{"id":20310999,"url":"https://github.com/progrium/dockerhub-tag","last_synced_at":"2025-04-11T16:07:00.770Z","repository":{"id":31014662,"uuid":"34573133","full_name":"progrium/dockerhub-tag","owner":"progrium","description":null,"archived":false,"fork":false,"pushed_at":"2015-09-09T19:32:36.000Z","size":248,"stargazers_count":7,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-14T02:21:28.042Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/progrium.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-25T15:09:30.000Z","updated_at":"2016-07-19T14:21:26.000Z","dependencies_parsed_at":"2022-09-08T17:22:28.869Z","dependency_job_id":null,"html_url":"https://github.com/progrium/dockerhub-tag","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fdockerhub-tag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fdockerhub-tag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fdockerhub-tag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/progrium%2Fdockerhub-tag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/progrium","download_url":"https://codeload.github.com/progrium/dockerhub-tag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248438498,"owners_count":21103409,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T17:35:22.864Z","updated_at":"2025-04-11T16:07:00.742Z","avatar_url":"https://github.com/progrium.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Did you ever find yourself creating automated builds by hand on http://hub.docker.com for each new git tag?\nWhy is it called *automated* build, if you can’t create a new one automatically? This project helps to\ndo the missing step.\n\nThere are plenty of articles describing a process where a central continuous build server (jenkins/travis/circleCI) builds\nthe image locally, and than **pushes** it to DockerHub. The end result of such a process **is not an automated build**. \nDocker images which aren’t automated builds, considered a security risk and therefore should be voided.\n\nPlease note that the main purpose of this tool is: to be able to create a new **automated** DockerHub build from cli,\nso it can be built easily integrated into any CI server/process.\n\n## Installation\n\n```\ngo get github.com/progrium/dockerhub-tag\n```\n\n## Usage\n\n```\nUsage:\n  dockerhub-tag list   \u003cdockerRepo\u003e                                   [--verbose|-v]\n  dockerhub-tag add    \u003cdockerRepo\u003e \u003cdockerTag\u003e \u003cgitTag\u003e \u003clocation\u003e   [--verbose|-v]\n  dockerhub-tag set    \u003cdockerRepo\u003e \u003cdockerTag\u003e \u003cgitTag\u003e \u003clocation\u003e   [--verbose|-v]\n  dockerhub-tag delete \u003cdockerRepo\u003e \u003cdockerTag\u003e                       [--verbose|-v]\n```\n\n- **list** : Lists all automated buils in a table format.\n- **add** : Creates a new automated build pointing to a git **Tag** reference\n- **set** : Creates a new automated build pointing to a git **Tag** reference, while deletes all other **Tag**. (Branches are untouched)\n- **delete** : Deletes a Tag by name.\n\n## Authentication\n\nVia environment variables\n```\nexport DOCKERHUB_USERNAME=yourname\nexport DOCKERHUB_PASSWORD=Id0ntt3lU\n```\n\n## Example\n\n```\ndockerhub-tag create gliderlabs/registrator 0.4.0 0.4.0 /\n```\n\n## Single Dockerhub tag policy\n\nDocker images are binary artifacts, so whenever you create a docker image tag based on\na github tag, it should be built only once.\n\nThink about how you should never change a git tag, once you pushed it to the central repo.\n\nIt also creates unnecessary load on hub.dockler.com server if you rebuild the same\nold (0.1.0, 0.1.1 0.1.2) docker images without any change.\n\n## Build once policy\n\nWhile developing on a github branch, you will rebuild a docker image with the same tag,\nlike `gliderlabs/registrator:master`. But for **tagged** github version you want a matching\ndocker image tag built only once. \n\nIt wouldn’t make sense to build `gliderlabs/registrator:v6` more than once, as it might\ncreate a different docker image, resulting a potentially different behaviour, depending on\nthe exact time of the docker pull.\n\nWhen you use `dockerhub-tag set`, it ensures to have a single git tag based automated build.\nBut when you push a change to a github branch, which has an automated build of branch type,\nyou will rebuild the tag type automated build as well.\n\nTo fulfill the build-once policy, you would need a mechanism to delete the tag based\nautomated build, after a successful build. But even than, while the tag based build\nprocesses, one can push to a branch, triggering a new tag build (see the next section\nabout triggers)\n\nSo right now, your best option is to have 1 single tag based automated build, maintained\nwith `dockerhub-tag set`\n\n## Triggers\n\nSince the new DockerHub version, the build trigger mechanism also changed. Previously the creation of \na new automated build, triggered the automated build process. At the new DockerHub version, you have\nto explicitly trigger the build.\n\nTheoretically there is a way to trigger only selected automated builds with **token based triggers**.\nThe documention shows an example:\n```\n# Trigger by Source tag named v1.1\n$ curl \\\n  -H \"Content-Type: application/json\" \\\n  --data '\u0026#123;\"source_type\": \"Tag\", \"source_name\": \"v1.1\"\u0026#125;' \\\n  -X POST \\\n  https://registry.hub.docker.com/u/gliderlabs/registrator/trigger/12345678-1a1a-1234-abcd-1234567890ab/\n```\nUnfortunately, it seems that it still triggers all the automated builds.\n\n## Makefile\n\nYou can trigger dockerhub tag creation by `make release`, with a couple of lines:\n\n```\nDOCKERHUB_REPO=progrium/dockerhub-tag\nGITHUB_REPO=progrium/dockerhub-tag\nDOCKERFILE_LOCATION=/\nVERSION=$(shell cat VERSION)\n\ndeps:\n\tgo get github.com/progrium/gh-release/...\n\tgo get github.com/progrium/dockerhub-tag\n\nrelease:\n\tgh-release create $(GITHUB_REPO) $(VERSION)\n\tdockerhub-tag set $(DOCKERHUB_REPO) $(VERSION) $(VERSION) $(DOCKERFILE_LOCATION)\n```\n## CircleCI\n\n```\ndeployment:\n  release:\n    branch: release\n    commands:\n      - make release\n```\n\nPlease remember to set env vars at **Project Settings / Environment variables**:\n- DOCKERHUB_USERNAME: authentication on hub.docker.com\n- DOCKERHUB_PASSWORD: credential on hub.docker.com\n- GITHUB_ACCESS_TOKEN: for creating the tag on github.com\n\n## tl;dr\n\nUnfortunately none of the registry api versions gives you access to automated builds.\n- [registry api v1](https://docs.docker.com/reference/api/registry_api/)\n- [registry api v2](https://docs.docker.com/registry/spec/api/)\n\nYou can create docker image tags for **non**automated builds only:\n- see [CenturyLinkLabs/docker-reg-client PR#3](https://github.com/CenturyLinkLabs/docker-reg-client/pull/3)\n- see [godoc](https://github.com/CenturyLinkLabs/docker-reg-client/blob/master/registry/doc.go#L48-L51)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrium%2Fdockerhub-tag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogrium%2Fdockerhub-tag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrium%2Fdockerhub-tag/lists"}