-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_image.sh
executable file
·84 lines (71 loc) · 1.8 KB
/
build_image.sh
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
#!/bin/bash
#
# by TS, May 2019
#
VAR_MYNAME="$(basename "$0")"
# ----------------------------------------------------------
# Outputs CPU architecture string
#
# @param string $1 debian_rootfs|debian_dist
#
# @return int EXITCODE
function _getCpuArch() {
case "$(uname -m)" in
x86_64*)
echo -n "amd64"
;;
i686*)
if [ "$1" = "qemu" ]; then
echo -n "i386"
elif [ "$1" = "s6_overlay" -o "$1" = "alpine_dist" ]; then
echo -n "x86"
else
echo -n "i386"
fi
;;
aarch64*)
if [ "$1" = "debian_rootfs" ]; then
echo -n "arm64v8"
elif [ "$1" = "debian_dist" ]; then
echo -n "arm64"
else
echo "$VAR_MYNAME: Error: invalid arg '$1'" >/dev/stderr
return 1
fi
;;
armv7*)
if [ "$1" = "debian_rootfs" ]; then
echo -n "arm32v7"
elif [ "$1" = "debian_dist" ]; then
echo -n "armhf"
else
echo "$VAR_MYNAME: Error: invalid arg '$1'" >/dev/stderr
return 1
fi
;;
*)
echo "$VAR_MYNAME: Error: Unknown CPU architecture '$(uname -m)'" >/dev/stderr
return 1
;;
esac
return 0
}
_getCpuArch debian_dist >/dev/null || exit 1
# ----------------------------------------------------------
cd build-ctx || exit 1
# ----------------------------------------------------------
LVAR_DEBIAN_DIST="$(_getCpuArch debian_dist)"
LVAR_DEBIAN_RELEASE="stretch"
LVAR_DEBIAN_VERSION="9.13"
LVAR_MS_VER="1.14.1"
LVAR_IMAGE_NAME="mail-mailslurper-$LVAR_DEBIAN_DIST"
LVAR_IMAGE_VER="$LVAR_MS_VER"
LVAR_SRC_OS_IMAGE="tsle/os-debian-${LVAR_DEBIAN_RELEASE}-${LVAR_DEBIAN_DIST}:${LVAR_DEBIAN_VERSION}"
docker pull $LVAR_SRC_OS_IMAGE || exit 1
echo
docker build \
--build-arg CF_SRC_OS_IMAGE="$LVAR_SRC_OS_IMAGE" \
--build-arg CF_CPUARCH_DEB_DIST="$LVAR_DEBIAN_DIST" \
--build-arg CF_MS_VERSION="$LVAR_MS_VER" \
-t "$LVAR_IMAGE_NAME":"$LVAR_IMAGE_VER" \
.