Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the best practices for tagging Docker Hub versions

I have a Docker Hub container that runs an application. Normally it will run the application by cloning the source git repo but in the case that I'd like to run a specific version, the application has tagged various releases. For example I can do a

git clone https://github.com/author/application.git
git checkout release-1.0.0

As the Docker Hub maintainer, I'd like to mirror the releases of the software with the container. Are there any other options besides just manually doing it when a release comes out?

Right now my Dockerfile contains something like this:

ENV APP_VER=2.0.0
RUN git clone ...; git checkout ${APP_VER}

In this example, I would keep a tagged branch of a docker file that sets the APP_VER to 2.1.0 and then Docker Hub supports that, but if I make changes to the repo, it's not clear how I would not make changes to that Dockerfile of each branch.

like image 945
Lizbeth Avatar asked Jul 03 '16 18:07

Lizbeth


1 Answers

You should be able to do what you are describing via Docker Hub's Automated Build and in build settings, set up the pattern matching between your Github tag Name and the Docker Tag Name. You can use wildcards and the variable {sourceref}`, "which refers to the source branch/tag name".

Whenever you push a new image with a Docker tag that matches a Github tag, it will pull the matching Dockerfile -- the previous tags will remain untouched. So someone can pull an older Docker image and the matching Github code by using the tag as a reference as you mentioned:

ENV APP_VER=2.1.0
RUN git clone ... app.git; git -C app checkout ${APP_VER}

In this case, it assumes you have Docker Hub set up to match the values and each tag (Docker image and Github) is 2.1.0

I'm not really sure what you mean by "each branch", that may be part of the confusion, especially if you're used to SVN. In git, a tag isn't tied to a branch but rather a specific commit (or ~point in time), so when you retrieve that tag, it's always going to use the same version of the code as it was when that commit was made. (Typically the same time as a release was cut.)

like image 118
ldg Avatar answered Sep 20 '22 14:09

ldg