-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·51 lines (37 loc) · 1.42 KB
/
build
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
#!/bin/sh -eu
set -eu
REFRESH_DOCKER_IMAGES=' buildpack-deps:focal-scm '
progname="$(basename "$0" .sh)"
note() { printf >&2 '%s: %s\n' "$progname" "$*"; }
die() { for x; do note "$x"; done; exit 1; }
[ $# -eq 0 ] || die "no build parameters are accepted"
# Use an environment variable to build as something other than 'keybase'
: "${IMAGE:=keybase}"
readonly IMAGE
cd "$(dirname "$0")"
# One of the files we know needs to be inside the image, as a sanity check.
require=keybase.is-up-to-date
test -f "$require" || die "missing required file: $require"
# Make sure that the keybase runtime user matches the invoker's
# run-time user.
kb_uid=$(id -u)
build() {
docker build --build-arg "KEYBASE_UID=$kb_uid" "$@" .
}
for dep in $REFRESH_DOCKER_IMAGES; do
docker pull -- "$dep"
done
build --target root -t "$IMAGE:latest-root"
build -t "$IMAGE:latest"
# We don't need the full permissions to just ask keybase its version,
# nor a home-dir created.
full_version="$(docker run --rm "$IMAGE:latest" keybase --version)"
# Should look something like:
# keybase version 5.2.0-20200130211428+cf82db8320
# (unless you also allocate a tty and get extra junk)
short_version="${full_version##* }"
short_version="${short_version%%-*}"
note "mapping '${full_version}' to '${short_version}' for tagging"
docker tag "$IMAGE:latest" "$IMAGE:${short_version}"
docker tag "$IMAGE:latest-root" "$IMAGE:${short_version}-root"
docker image list "$IMAGE"