-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·126 lines (108 loc) · 3.02 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env bash
set -e
help() {
echo "Build script
Copyright (C) 2022, Freelight, Inc
Version: $(cat ./VERSION)
Usage: ./build.sh [options]
Options:
--name(=string) Specify a custom name to use when building.
--type(=string) The type of image to build.
--window_manager(=string) The window manager to use when building.
--ubuntu_version(=string) The ubuntu version to use.
--base_image(=string) The base image to use when building.
--dockerfile(=string) Specify a dockerfile to use to build.
--build_dir(=string) Specify a directory to build in.
--version(=string) Set the image version.
--skip_latest Do not set this image tag as the latest.
--timezone(=string) Set the default timezone.
Types:
all Build all docker images.
base Build the base docker images.
developer Build the developer docker image.
steam Build the steam docker image.
Window Manager:
all Build all window manager docker images.
gnome Build only gnome type docker images.
mate Build only mate type docker images.
xfce Build only xfce type docker images.
Base images you can specify any base image you'd like to use, or select from:
Base Images:
nvidia-opengl Use the base nvidia glx image. This will only work on
headless servers that do NOT have a GPU connected to X11.
"
exit 1
}
NAME=""
DOCKERFILE=""
BUILD_DIR="."
IS_LATEST="1"
VERSION=$(cat ./VERSION)
TYPE="all"
WINDOW_MANAGER="mate"
BASEIMAGE="ubuntu:20.04"
UBUNTU_VERSION="20.04"
TIMEZONE="America/Phoenix"
while :; do
case $1 in
-h|-\?|--help)
help
exit 0
;;
--name=?*)
NAME="${1#*=}"
;;
--dockerfile=?*)
DOCKERFILE="${1#*=}"
;;
--type=?*)
TYPE="${1#*=}"
;;
--window_manager=?*)
WINDOW_MANAGER="${1#*=}"
;;
--base_image=?*)
BASEIMAGE="${1#*=}"
;;
--ubuntu_version=?*)
UBUNTU_VERSION="${1#*=}"
;;
--build_dir=?*)
BUILD_DIR="${1#*=}"
;;
--version=?*)
VERSION="${1#*=}"
;;
--timezone=?*)
TIMEZONE="${1#*=}"
;;
--skip_latest)
IS_LATEST="0"
;;
*)
break
esac
shift
done
if [ "$TYPE" == "all" ] || [ "$TYPE" == "base" ]; then
cd ./images/
./build.sh $TYPE $WINDOW_MANAGER $BASEIMAGE $UBUNTU_VERSION
cd ..;
fi
if [ "$TYPE" == "all" ] || [ "$TYPE" == "developer" ] || [ "$TYPE" == "steam" ]; then
cd ./workspaces/
./build.sh $TYPE $WINDOW_MANAGER $UBUNTU_VERSION
cd ..;
fi
if [ "$DOCKERFILE" != "" ]; then
if [ "$NAME" == "" ]; then
echo "You must set an image name using --name"
exit 1
fi
docker build --progress=plain -t ${NAME}:${VERSION} \
--build-arg TIMEZONE=$TIMEZONE --build-arg BASEIMAGE="$BASEIMAGE" \
-f ${DOCKERFILE} ${BUILD_DIR}
if [ "$IS_LATEST" == "1" ]; then
docker tag ${NAME}:${VERSION} ${NAME}:latest;
fi
fi