aboutsummaryrefslogtreecommitdiffstats
path: root/nms/makedockerfiles.sh
blob: 6c7e3dae28593edb28ff979fa88e1e4d835aeb31 (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