Skip to content

Commit 77738fc

Browse files
committed
Updated dockerfile, docker-init.sh, updatedb script, and a new docker/build script.
- Legacy-Id: 12282
1 parent 10fa4af commit 77738fc

1 file changed

Lines changed: 128 additions & 0 deletions

File tree

docker/build

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/bin/bash
2+
3+
version=0.10
4+
program=${0##*/}
5+
progdir=${0%/*}
6+
if [ "$progdir" = "$program" ]; then progdir="."; fi
7+
if [ "$progdir" = "." ]; then progdir="$PWD"; fi
8+
parent=$(dirname $progdir)
9+
if [ "$parent" = "." ]; then parent="$PWD"; fi
10+
11+
export LANG=C
12+
13+
# ----------------------------------------------------------------------
14+
function usage() {
15+
cat <<EOF
16+
NAME
17+
$program - Build a docker datatracker image.
18+
19+
SYNOPSIS
20+
$program [OPTIONS] ARGS
21+
22+
DESCRIPTION
23+
24+
This script builds a debian-based docker image which has been
25+
set up with the dependencies needed to easily run the IETF
26+
datatracker in development mode. It uses docker/Dockerfile;
27+
i.e., the Dockerfile in the same directory as this script.
28+
It assumes that the user has upload rights for the docker
29+
ietf/datatracker-environment repository, in order to push the
30+
image.
31+
32+
EOF
33+
echo -e "OPTIONS"
34+
if [ "$(uname)" = "Linux" ]; then
35+
egrep "^[ ]+[-][A-Za-z| -]+\*?\)[ ]+[A-Za-z].+#" $0 | tr -s "\t|" "\t," | sed -r -e 's/\)[ \t]+([A-Z]+)=\$2[^#]*#/=\1\t/' -e 's/\)[^#]*#/\t/'
36+
else
37+
egrep "^[ ]+[-][A-Za-z| -]+\*?\)[ ]+[A-Za-z].+#" $0 | sed 's/\|.*\$2[^#]*#/ /'| sed -E 's/\|.*\)[^#]*#/ /'
38+
fi
39+
cat <<EOF
40+
41+
FILES
42+
43+
AUTHOR
44+
Written by Henrik Levkowetz, <henrik@levkowetz.com>
45+
46+
COPYRIGHT
47+
48+
Copyright (c) 2016 IETF Trust and the persons identified as authors of
49+
the code. All rights reserved. License 'Simplified BSD', as specified
50+
in http://opensource.org/licenses/BSD-3-Clause.
51+
52+
EOF
53+
54+
}
55+
56+
# ----------------------------------------------------------------------
57+
function die() {
58+
echo -e "\n$program: error: $*" >&2
59+
exit 1
60+
}
61+
62+
function note() {
63+
if [ -n "$VERBOSE" ]; then echo -e "$*"; fi
64+
}
65+
66+
# ----------------------------------------------------------------------
67+
function version() {
68+
echo -e "$program $version"
69+
}
70+
71+
# ----------------------------------------------------------------------
72+
trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR
73+
74+
75+
# ----------------------------------------------------------------------
76+
# Option parsing
77+
78+
# Options
79+
shortopts=ht:vV
80+
longopts=help,tag=,verbose,version
81+
82+
# Default values
83+
BRANCH=$(svn log -v ^/tags -l 2 | grep 'A /tags/[1-9]' | awk '{print $2}')
84+
TAG=${BRANCH##*/}
85+
86+
if [ "$(uname)" = "Linux" ]; then
87+
args=$(getopt -o "$shortopts" --long "$longopts" -n '$program' -- $SV "$@")
88+
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
89+
eval set -- "$args"
90+
sed="sed -r"
91+
else
92+
# Darwin, BSDs
93+
args=$(getopt -o$shortopts $SV $*)
94+
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
95+
set -- $args
96+
sed="sed -E"
97+
fi
98+
99+
while true ; do
100+
case "$1" in
101+
-h| --help) usage; exit;; # Show this help, then exit
102+
-t| --tag) TAG=$2; shift;; # Use this docker image tag, instead of the latest svn tags name
103+
-v| --verbose) VERBOSE=1;; # Be more talkative
104+
-V| --version) version; exit;; # Show program version, then exit
105+
--) shift; break;;
106+
*) die "Internal error, inconsistent option specification: '$1'";;
107+
esac
108+
shift
109+
done
110+
111+
# ----------------------------------------------------------------------
112+
# The program itself
113+
114+
if [ "$(uname)" != "Linux" ]; then
115+
if [ -n "$(type -p docker-machine)" ]; then
116+
machine=$(type -p docker-machine)
117+
else
118+
die "Could not find boot2docker or docker-machine -- you need to set one of those before running this script."
119+
fi
120+
else
121+
die "Didn't expect to run this script on Linux -- are you inside docker?"
122+
fi
123+
124+
docker rmi -f ietf/datatracker-environment:trunk
125+
docker build -t ietf/datatracker-environment:$TAG docker/
126+
docker tag $(docker images -q | head -n 1) ietf/datatracker-environment:latest
127+
docker push ietf/datatracker-environment:latest
128+
docker push ietf/datatracker-environment:$TAG

0 commit comments

Comments
 (0)