Bug 1212877: improve build.sh to run from any directory; r=wcosta DONTBUILD
authorDustin J. Mitchell <dustin@mozilla.com>
Thu, 08 Oct 2015 10:43:20 -0400
changeset 266959 f68b62d3af7f66075303094a4eae7424b5bc6248
parent 266958 4a9ccb4535beb551579442f761154cffce110809
child 266960 a4e0f0475b789412d8f575661b88a53c9589807d
push id29504
push usercbook@mozilla.com
push dateFri, 09 Oct 2015 09:43:23 +0000
treeherdermozilla-central@d01dd42e654b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswcosta
bugs1212877
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1212877: improve build.sh to run from any directory; r=wcosta DONTBUILD
testing/docker/build.sh
--- a/testing/docker/build.sh
+++ b/testing/docker/build.sh
@@ -1,19 +1,22 @@
 #! /bin/bash -e
 
 # This file is a wrapper around docker build with specific concerns around image
 # versions and registry deployment... It also attempts to detect any potential
 # missing dependencies and warns you about them.
 
+gecko_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
+
 usage() {
-  echo "Build a docker image in the given folder (and tag it)"
+  echo "Build a docker image (and tag it)"
   echo
-  echo "$0 <folder>"
+  echo "$0 <image-name>"
   echo
+  echo "  Images are defined in testing/docker/<image-name>."
   echo "  For more see: $PWD/README.md"
   echo
 }
 
 usage_err() {
   echo $1
   echo
   usage
@@ -26,52 +29,53 @@ find_registry() {
   if [ -f $reg ];
   then
     echo $folder
     return
   fi
 }
 
 build() {
-  local folder=$1
-  local folder_reg="$1/REGISTRY"
-  local folder_ver="$1/VERSION"
+  local image_name=$1
+  local folder="$gecko_root/testing/docker/$image_name"
+  local folder_reg="$folder/REGISTRY"
+  local folder_ver="$folder/VERSION"
 
-  if [ "$folder" == "" ];
+  if [ "$image_name" == "" ];
   then
     usage
     return
   fi
 
-  test -d "$folder" || usage_err "Unknown folder: $folder"
+  test -d "$folder" || usage_err "Unknown image: $image_name"
   test -f "$folder_ver" || usage_err "$folder must contain VERSION file"
 
   # Fallback to default registry if one is not in the folder...
   if [ ! -f "$folder_reg" ]; then
     folder_reg=$PWD/REGISTRY
   fi
 
   local registry=$(cat $folder_reg)
   local version=$(cat $folder_ver)
 
   test -n "$registry" || usage_err "$folder_reg is empty aborting..."
   test -n "$version" || usage_err "$folder_ver is empty aborting..."
 
-  local tag="$registry/$folder:$version"
+  local tag="$registry/$image_name:$version"
 
   if [ -f $folder/build.sh ]; then
     shift
     $folder/build.sh -t $tag $* || exit 1
   else
     # use --no-cache so that we always get the latest updates from yum
     # and use the latest version of system-setup.sh
-    docker build --no-cache -t $tag $folder || exit 1
+    ( cd $folder/.. && docker build --no-cache -t $tag $image_name ) || exit 1
   fi
 
-  echo "Success built $folder and tagged with $tag"
+  echo "Success built $image_name and tagged with $tag"
   echo "If deploying now you can run 'docker push $tag'"
 }
 
 if ! which docker > /dev/null; then
   echo "Docker must be installed read installation instructions at docker.com"
   echo
   usage
   exit 1