aboutsummaryrefslogtreecommitdiffstats
path: root/nms/makedockerfiles.sh
blob: 6c8e136872e2fad463df0e77899e46aba8c05bdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
awk -v TARGET=/dev/null '
BEGIN {
	system("mkdir -p build")
}
/^@template/ {
	TARGET="build/Dockerfile."$2;
	TARGETS[ntargets++]=$2;
	print "# Generated" > TARGET
	next;
}
{
	print > TARGET
}
END {
	print "#! /bin/sh" > "build/build.sh"
	print "set -e" > "build/build.sh"
	for (x in TARGETS) {
		a = TARGETS[x]
		print "echo Building "a > "build/build.sh"
		print "echo Logs: build/"a".log" > "build/build.sh"
		print "docker build -t "a" -f build/Dockerfile."a" . > build/"a".log 2>&1 || cat build/"a".log" > "build/build.sh"
	}
	system("chmod +x build/build.sh")
}' < Dockerfile.in
build/build.sh