Allow to provide a custom tag for docker image (#15)

Allow to provide a custom tag for docker image (#15)

Our other projects allow us to call make TAG=something to create a custom tag when creating a docker image.

This patch aims to do something similar using rake docker:build TAG=something.

diff --git a/ b/
index 08bb0fa..3137d4a 100644
--- a/
+++ b/
@@ -493,6 +493,10 @@ docker:build` to make a local container for testing, and `rake
 docker:publish` to build and push a container image to
+A custom tag can be provided by setting the `TAG` environment variable. For
+example: `rake docker:build TAG=my_custom_tag`. Issuing `rake docker:publish
+TAG=my_custom_tag` will publish this custom tag but not the `latest` one.
 # Licence
diff --git a/Rakefile b/Rakefile
index 2a54399..73e5059 100644
--- a/Rakefile
+++ b/Rakefile
@@ -47,7 +47,7 @@ :test do |t|
 namespace :docker do
-  tag = docker_tagify(version())
+  tag = docker_tagify(ENV["TAG"] || version)
   desc "Build a new docker image"
   task :build do
@@ -58,6 +58,6 @@ namespace :docker do
   desc "Publish a new docker image"
   task publish: :build do
     sh "docker push discourse/mobystash:#{tag}"
-    sh "docker push discourse/mobystash:latest"
+    sh "docker push discourse/mobystash:latest" unless ENV["TAG"]

GitHub sha: baacf21d5be3b0f64268b2330f5172406fc2b3ff

This commit appears in #15 which was approved by saj. It was merged by Flink.