-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·84 lines (71 loc) · 1.92 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
80
81
82
83
84
#!/bin/bash
# error codes
# 2 Invalid base image
declare -A base_images
base_images[sid]=debian:sid-slim
base_images[trixie]=debian:trixie-slim
base_images[bookworm]=debian:bookworm-slim
base_images[buster]=debian:buster-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
base_images[bionic]=ubuntu:bionic
declare -A local_tag
local_tag[sid]=local-sid
local_tag[trixie]=local-trixie
local_tag[bookworm]=local-bookworm
local_tag[buster]=local-buster
local_tag[bullseye]=local-bullseye
local_tag[noble]=local-noble
local_tag[mantic]=local-mantic
local_tag[lunar]=local-lunar
local_tag[kinetic]=local-kinetic
local_tag[jammy]=local-jammy
local_tag[focal]=local-focal
local_tag[bionic]=local-bionic
DEFAULT_BASE_IMAGE=bookworm
DEFAULT_TAG=local
DEFAULT_GIT_VERSION=version-0.23.17
tag=""
git_branch="$DEFAULT_GIT_VERSION"
while getopts b:t:p:g: flag
do
case "${flag}" in
b) base_image=${OPTARG};;
t) tag=${OPTARG};;
g) git_branch=${OPTARG};;
esac
done
echo "base_image: $base_image";
echo "tag: $tag";
echo "git_branch: [$git_branch]";
if [ -z "${base_image}" ]; then
base_image=$DEFAULT_BASE_IMAGE
fi
expanded_base_image=${base_images[$base_image]}
if [ -z "${expanded_base_image}" ]; then
echo "invalid base image ["${base_image}"]"
exit 2
fi
if [[ -z "$tag" ]]; then
select_tag=${local_tag[$base_image]}
if [[ -n "$select_tag" ]]; then
tag=$select_tag
else
tag=$DEFAULT_TAG
fi
fi
if [ -z "${git_branch}" ]; then
git_branch="${DEFAULT_GIT_VERSION}"
fi
echo "Base Image: ["$expanded_base_image"]"
echo "Tag: ["$tag"]"
echo "Git Branch: ["$git_branch"]"
docker build . \
--build-arg BASE_IMAGE=${expanded_base_image} \
--build-arg USE_GIT_BRANCH=${git_branch} \
-t giof71/mpd-compiler:$tag