From 77738fcc78d83ed2c698ca856cf08b8de486e29a Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Tue, 8 Nov 2016 16:09:08 +0000 Subject: [PATCH] Updated dockerfile, docker-init.sh, updatedb script, and a new docker/build script. - Legacy-Id: 12282 --- docker/build | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100755 docker/build diff --git a/docker/build b/docker/build new file mode 100755 index 000000000..d7afe098e --- /dev/null +++ b/docker/build @@ -0,0 +1,128 @@ +#!/bin/bash + +version=0.10 +program=${0##*/} +progdir=${0%/*} +if [ "$progdir" = "$program" ]; then progdir="."; fi +if [ "$progdir" = "." ]; then progdir="$PWD"; fi +parent=$(dirname $progdir) +if [ "$parent" = "." ]; then parent="$PWD"; fi + +export LANG=C + +# ---------------------------------------------------------------------- +function usage() { + cat < + +COPYRIGHT + + Copyright (c) 2016 IETF Trust and the persons identified as authors of + the code. All rights reserved. License 'Simplified BSD', as specified + in http://opensource.org/licenses/BSD-3-Clause. + +EOF + +} + +# ---------------------------------------------------------------------- +function die() { + echo -e "\n$program: error: $*" >&2 + exit 1 +} + +function note() { + if [ -n "$VERBOSE" ]; then echo -e "$*"; fi +} + +# ---------------------------------------------------------------------- +function version() { + echo -e "$program $version" +} + +# ---------------------------------------------------------------------- +trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR + + +# ---------------------------------------------------------------------- +# Option parsing + +# Options +shortopts=ht:vV +longopts=help,tag=,verbose,version + +# Default values +BRANCH=$(svn log -v ^/tags -l 2 | grep 'A /tags/[1-9]' | awk '{print $2}') +TAG=${BRANCH##*/} + +if [ "$(uname)" = "Linux" ]; then + args=$(getopt -o "$shortopts" --long "$longopts" -n '$program' -- $SV "$@") + if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi + eval set -- "$args" + sed="sed -r" +else + # Darwin, BSDs + args=$(getopt -o$shortopts $SV $*) + if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi + set -- $args + sed="sed -E" +fi + +while true ; do + case "$1" in + -h| --help) usage; exit;; # Show this help, then exit + -t| --tag) TAG=$2; shift;; # Use this docker image tag, instead of the latest svn tags name + -v| --verbose) VERBOSE=1;; # Be more talkative + -V| --version) version; exit;; # Show program version, then exit + --) shift; break;; + *) die "Internal error, inconsistent option specification: '$1'";; + esac + shift +done + +# ---------------------------------------------------------------------- +# The program itself + +if [ "$(uname)" != "Linux" ]; then + if [ -n "$(type -p docker-machine)" ]; then + machine=$(type -p docker-machine) + else + die "Could not find boot2docker or docker-machine -- you need to set one of those before running this script." + fi +else + die "Didn't expect to run this script on Linux -- are you inside docker?" +fi + +docker rmi -f ietf/datatracker-environment:trunk +docker build -t ietf/datatracker-environment:$TAG docker/ +docker tag $(docker images -q | head -n 1) ietf/datatracker-environment:latest +docker push ietf/datatracker-environment:latest +docker push ietf/datatracker-environment:$TAG \ No newline at end of file