-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·80 lines (64 loc) · 1.7 KB
/
build.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
#!/bin/bash
declare -A base_images
base_images[bookworm]=debian:bookworm-slim
base_images[bullseye]=debian:bullseye-slim
base_images[noble]=ubuntu:noble
base_images[mantic]=ubuntu:mantic
base_images[lunar]=ubuntu:lunar
base_images[kinetic]=ubuntu:kinetic
base_images[jammy]=ubuntu:jammy
base_images[focal]=ubuntu:focal
DEFAULT_BASE_IMAGE=noble
DEFAULT_TAG=local
DEFAULT_USE_PROXY=N
DEFAULT_BUILD_MODE=full
DEFAULT_CACHE_MODE=""
tag=$DEFAULT_TAG
use_proxy=$DEFAULT_USE_PROXY
while getopts b:t:p:m:c: flag
do
case "${flag}" in
b) base_image=${OPTARG};;
t) tag=${OPTARG};;
p) proxy=${OPTARG};;
m) build_mode=${OPTARG};;
c) cache_mode=${OPTARG};;
esac
done
echo "base_image: $base_image";
echo "tag: $tag";
echo "proxy: $proxy";
echo "build_mode: $build_mode";
echo "cache_mode: $cache_mode";
if [ -z "${base_image}" ]; then
base_image=$DEFAULT_BASE_IMAGE
fi
if [ -z "${proxy}" ]; then
use_proxy="N"
else
use_proxy=$proxy
fi
if [[ -z ${base_images[$base_image]} ]]; then
echo "Image for ["$base_image"] not found"
select_base_image=${base_images[$DEFAULT_BASE_IMAGE]}
else
select_base_image=${base_images[$base_image]}
fi
if [[ -z "${build_mode}" ]]; then
build_mode=$DEFAULT_BUILD_MODE
fi
if [[ -z "${cache_mode}" ]]; then
cache_mode=$DEFAULT_CACHE_MODE
fi
echo "Base Image: ["$select_base_image"]"
echo "Tag: ["$tag"]"
echo "Build Mode: ["$build_mode"]"
echo "Proxy: ["$use_proxy"]"
cmd_line="docker build . ${cache_mode} \
--build-arg BASE_IMAGE=${select_base_image} \
--build-arg USE_APT_PROXY=${use_proxy} \
--build-arg BUILD_MODE=${build_mode} \
--progress=plain \
-t giof71/upmpdcli:$tag"
echo "cmd_line=[$cmd_line]"
eval "$cmd_line"