Merge branch '7751-mount-tmp' refs #7751
[arvados.git] / docker / build.sh
old mode 100644 (file)
new mode 100755 (executable)
index 6478f81..77aeb1f
@@ -1,42 +1,41 @@
 #! /bin/bash
 
-build_ok=true
-
-# Check that:
-#   * IP forwarding is enabled in the kernel.
-
-if [ "$(/sbin/sysctl --values net.ipv4.ip_forward)" != "1" ]
+# make sure a Ruby version greater than or equal to 1.9.3 is installed before proceeding
+if ! ruby -e 'exit RUBY_VERSION >= "1.9.3"' 2>/dev/null
 then
-    echo >&2 "WARNING: IP forwarding must be enabled in the kernel."
-    echo >&2 "Try: sudo sysctl net.ipv4.ip_forward=1"
-    build_ok=false
+    echo "Building the Arvados docker containers requires at least Ruby 1.9.3."
+    echo "Please install ruby 1.9.3 or higher before executing this script."
+    exit 1
 fi
 
-#   * Docker can be found in the user's path
-#   * The user is in the docker group
-#   * cgroup is mounted
-#   * the docker daemon is running
+function usage {
+    echo >&2
+    echo >&2 "usage: $0 [options]"
+    echo >&2
+    echo >&2 "Calling $0 without arguments will build all Arvados docker images"
+    echo >&2
+    echo >&2 "$0 options:"
+    echo >&2 "  -h, --help   Print this help text"
+    echo >&2 "  clean        Clear all build information"
+    echo >&2 "  realclean    clean and remove all Arvados Docker images except arvados/debian"
+    echo >&2 "  deepclean    realclean and remove arvados/debian, crosbymichael/skydns and "
+    echo >&2 "               crosbymichael/skydns Docker images"
+    echo >&2
+}
 
-if ! docker images > /dev/null 2>&1
-then
-    echo >&2 "WARNING: docker could not be run."
-    echo >&2 "Please make sure that:"
-    echo >&2 "  * You have permission to read and write /var/run/docker.sock"
-    echo >&2 "  * a 'cgroup' volume is mounted on your machine"
-    echo >&2 "  * the docker daemon is running"
-    build_ok=false
+if [ "$1" = '-h' ] || [ "$1" = '--help' ]; then
+  usage
+  exit 1
 fi
 
-#   * config.yml exists
-if [ '!' -f config.yml ]
-then
-    echo >&2 "WARNING: no config.yml found in the current directory"
-    echo >&2 "Copy config.yml.example to config.yml and update it with settings for your site."
-    build_ok=false
-fi
+build_tools/build.rb
 
-# If ok to build, then go ahead and run make
-if $build_ok
-then
-    make $*
+if [[ "$?" == "0" ]]; then
+    DOCKER=`which docker.io`
+
+    if [[ "$DOCKER" == "" ]]; then
+      DOCKER=`which docker`
+    fi
+
+    DOCKER=$DOCKER /usr/bin/make -f build_tools/Makefile $*
 fi