forked from coreos/fleet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-aci
executable file
·90 lines (78 loc) · 1.74 KB
/
build-aci
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
set -e
if [ $# -ne 1 ]; then
echo "Usage: $0 tag" >/dev/stderr
exit 1
fi
tag=$1
tgt=$(mktemp -d)
# Build fleet inside
docker run -v $PWD:/opt/fleet google/golang:1.3.1 /bin/bash -c "cd /opt/fleet && ./build"
# Generate manifest into target tmp dir
cat <<DF >${tgt}/manifest
{
"acVersion" : "0.5.1",
"acKind" : "ImageManifest",
"name" : "coreos.com/fleetd",
"labels" : [
{
"value" : "${tag}",
"name" : "version"
},
{
"name" : "os",
"value" : "linux"
}
],
"app" : {
"exec" : [
"/bin/fleetd"
],
"user" : "0",
"group" : "0",
"mountPoints" : [
{
"name" : "machine-id",
"readOnly" : true,
"path" : "/etc/machine-id"
},
{
"path" : "/run/dbus/system_bus_socket",
"readOnly" : false,
"name" : "dbus-socket"
},
{
"path" : "/run/fleet/units",
"readOnly" : false,
"name" : "fleet-units"
},
{
"path" : "/etc/fleet",
"readOnly" : true,
"name" : "etc-fleet"
}
]
}
}
DF
# Create dirs and links
mkdir -p $tgt/rootfs/bin
mkdir -p $tgt/rootfs/etc/fleet
mkdir -p $tgt/rootfs/run/dbus
mkdir -p $tgt/rootfs/var
ln -s /run $tgt/rootfs/var/run
# Generate minimal hosts file
cat <<DF >${tgt}/rootfs/etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
DF
# Copy fleetd binary
cp bin/fleetd $tgt/rootfs/bin
# Create resolv.conf file
touch $tgt/rootfs/etc/resolv.conf
# Build ACI
actool build -overwrite $tgt fleetd-${tag}.aci
# Validate ACI
actool validate fleetd-${tag}.aci
# Cleanup
rm -rf $tgt