Docker Community Forums

Share and learn in the Docker community.

Way to Autobuild with Tags

build

#1

Hey, i´ve been using Docker for a while now and started with using Docker Cloud to Autobuild my Containers i make with Github.

Everything works fine, but there is a thing, i dont quite understand and thats the Tagging-system.

Atm i Tag my Builds with Stable and Testing. I started using a numeric system (0,1,2,3,4,…) but i was to silly to everytime change that number in the Autobuild process, if i only change little things in my Dockerfile or scripts.

My Question here is: Is there a way, to even make a simple numeric system for autobuilding and tagging possible? Or maybe a Tagging based on Date and Time or something like that?

I already read about hooks and such stuff, but i guess, i dont get it.

Can someone help me?


(Gary Forghetti) #2

Hi joly0

I use GitHub and tagging along with the Docker Hub Automated Build and Test.
See this example -> https://github.com/gforghetti/helloworld

I don’t automate the tag numbers, but you could add a script to your build automation to retrieve the latest git tag, increment it by 1 and then tag the new “build”.

🐳  gforghetti:[~/GitHub/helloworld] $ git tag
1.0.0
1.0.1
1.0.2
1.0.3
1.0.4
1.0.5
🐳  gforghetti:[~/GitHub/helloworld] $ git tag | tail -1
1.0.5
🐳  gforghetti:[~/GitHub/helloworld] $ new_tag=($(git tag | tail -1) + 1)
🐳  gforghetti:[~/GitHub/helloworld] $ echo $new_tag
1.0.6
🐳  gforghetti:[~/GitHub/helloworld] $ git tag $new_tag
🐳  gforghetti:[~/GitHub/helloworld] $ git push origin $new_tag
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Total 0 (delta 0), reused 0 (delta 0)
To github.com:gforghetti/helloworld.git
 * [new tag]         1.0.6 -> 1.0.6


#3

Can you explain this a bit deeper, i just started working with Github and automated Builds and i dont understand the part with the Script.

Sry, if i sound a bit dumb and annoy you, but i really want to learn new things, but this seems so different then anything i worked with.

I would be relly happy, if i get a helpfull answer.
Thank you


(Gary Forghetti) #4

Take a look at this page Custom build phase hooks in the Docker Hub Advanced Automated Builds documentation.

You can create a pre_build hook/script.


#5

Well, i have to come back to this, because it just doesnt work.

It always rejects to build, because it doesnt have write access to my github repository, although i correctly authorized Docker-cloud.

If i look into the Deploy -keys on Github it also says, its read-only.