forked from oap-project/cloudtik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-docker.sh
executable file
·180 lines (163 loc) · 6.87 KB
/
build-docker.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/bash
# This script is for users to build docker images locally. It is most useful for users wishing to edit the
# cloudtik-base, cloudtik-deps, or cloudtik images.
set -x
CLOUDTIK_VERSION=$(sed -n 's/__version__ = \"\(..*\)\"/\1/p' ./python/cloudtik/__init__.py)
GPU=""
BASE_IMAGE="ubuntu:focal"
WHEEL_URL="https://d30257nes7d4fq.cloudfront.net/downloads/cloudtik/cloudtik-${CLOUDTIK_VERSION}-cp37-cp37m-manylinux2014_x86_64.whl"
PYTHON_VERSION="3.7.7"
CONDA_ENV_NAME="cloudtik_py37"
IMAGE_TAG="nightly"
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--gpu)
GPU="-gpu"
BASE_IMAGE="nvidia/cuda:11.2.0-cudnn8-devel-ubuntu18.04"
;;
--base-image)
# Override for the base image.
shift
BASE_IMAGE=$1
;;
--no-cache-build)
NO_CACHE="--no-cache"
;;
--shas-only)
# output the SHA sum of each build. This is useful for scripting tests,
# especially when builds of different versions are running on the same machine.
# It also can facilitate cleanup.
OUTPUT_SHA=YES
;;
--wheel-to-use)
# Which wheel to use. This defaults to the latest nightly on python 3.7
echo "not implemented, just hardcode me :'("
exit 1
;;
--python-version)
# Python version to install. e.g. 3.7.7.
# Changing python versions may require a different wheel.
# If not provided defaults to 3.7.7
shift
PYTHON_VERSION=$1
;;
--release)
IMAGE_TAG=${CLOUDTIK_VERSION}
;;
--build-all)
BUILD_ALL=YES
;;
--build-dev)
BUILD_DEV=YES
;;
--build-spark)
BUILD_SPARK=YES
;;
--build-spark-native-sql)
BUILD_SPARK_NATIVE_SQL=YES
;;
--build-spark-optimized)
BUILD_SPARK_OPTIMIZED=YES
;;
--build-universe)
BUILD_UNIVERSE=YES
;;
--build-presto)
BUILD_PRESTO=YES
;;
--build-trino)
BUILD_TRINO=YES
;;
--build-ml)
BUILD_ML=YES
;;
--build-spark-benchmark)
BUILD_SPARK_BENCHMARK=YES
;;
--build-spark-native-sql-benchmark)
BUILD_SPARK_NATIVE_SQL_BENCHMARK=YES
;;
--build-spark-optimized-benchmark)
BUILD_SPARK_OPTIMIZED_BENCHMARK=YES
;;
*)
echo "Usage: build-docker.sh [ --base-image ] [ --no-cache-build ] [ --shas-only ] [ --wheel-to-use ] [ --python-version ]"
echo "Images to build options:"
echo "[ --build-all ] [ --build-dev ] [ --build-spark ] [ --build-optimized ] [ --build-spark-native-sql ]"
echo "[ --build-universe ] [ --build-presto ] [ --build-trino ] [ --build-ml ]"
echo "[ --build-spark-benchmark ] [ --build-optimized-benchmark ] [ --build-spark-native-sql-benchmark ]"
exit 1
esac
shift
done
WHEEL_DIR=$(mktemp -d)
wget --quiet "$WHEEL_URL" -P "$WHEEL_DIR"
WHEEL="$WHEEL_DIR/$(basename "$WHEEL_DIR"/*.whl)"
# Build cloudtik-base, cloudtik-deps, and cloudtik.
for IMAGE in "cloudtik-base"
do
cp "$WHEEL" "docker/$IMAGE/$(basename "$WHEEL")"
if [ $OUTPUT_SHA ]; then
IMAGE_SHA=$(docker build $NO_CACHE --build-arg GPU="$GPU" --build-arg BASE_IMAGE="$BASE_IMAGE" --build-arg WHEEL_PATH="$(basename "$WHEEL")" --build-arg PYTHON_VERSION="$PYTHON_VERSION" --build-arg CONDA_ENV_NAME="$CONDA_ENV_NAME" -q -t cloudtik/$IMAGE:$IMAGE_TAG$GPU docker/$IMAGE)
echo "cloudtik/$IMAGE:$IMAGE_TAG$GPU SHA:$IMAGE_SHA"
else
docker build $NO_CACHE --build-arg GPU="$GPU" --build-arg BASE_IMAGE="$BASE_IMAGE" --build-arg WHEEL_PATH="$(basename "$WHEEL")" --build-arg PYTHON_VERSION="$PYTHON_VERSION" --build-arg CONDA_ENV_NAME="$CONDA_ENV_NAME" -t cloudtik/$IMAGE:$IMAGE_TAG$GPU docker/$IMAGE
fi
rm "docker/$IMAGE/$(basename "$WHEEL")"
done
for IMAGE in "cloudtik-deps" "cloudtik"
do
cp "$WHEEL" "docker/$IMAGE/$(basename "$WHEEL")"
if [ $OUTPUT_SHA ]; then
IMAGE_SHA=$(docker build $NO_CACHE --build-arg GPU="$GPU" --build-arg BASE_IMAGE=$IMAGE_TAG --build-arg WHEEL_PATH="$(basename "$WHEEL")" --build-arg PYTHON_VERSION="$PYTHON_VERSION" -q -t cloudtik/$IMAGE:$IMAGE_TAG$GPU docker/$IMAGE)
echo "cloudtik/$IMAGE:$IMAGE_TAG$GPU SHA:$IMAGE_SHA"
else
docker build $NO_CACHE --build-arg GPU="$GPU" --build-arg BASE_IMAGE=$IMAGE_TAG --build-arg WHEEL_PATH="$(basename "$WHEEL")" --build-arg PYTHON_VERSION="$PYTHON_VERSION" -t cloudtik/$IMAGE:$IMAGE_TAG$GPU docker/$IMAGE
fi
rm "docker/$IMAGE/$(basename "$WHEEL")"
done
# Build the current source
if [ $BUILD_DEV ] || [ $BUILD_ALL ]; then
git rev-parse HEAD > ./docker/cloudtik-dev/git-rev
git archive -o ./docker/cloudtik-dev/cloudtik.tar "$(git rev-parse HEAD)"
if [ $OUTPUT_SHA ]; then
IMAGE_SHA=$(docker build --no-cache -q -t cloudtik/cloudtik-dev docker/cloudtik-dev)
echo "cloudtik/cloudtik-dev:latest SHA:$IMAGE_SHA"
else
docker build --no-cache -t cloudtik/cloudtik-dev docker/cloudtik-dev
fi
rm ./docker/cloudtik-dev/cloudtik.tar ./docker/cloudtik-dev/git-rev
fi
rm -rf "$WHEEL_DIR"
if [ $BUILD_SPARK ] || [ $BUILD_ALL ]; then
docker build $NO_CACHE --build-arg BASE_IMAGE=$IMAGE_TAG -t cloudtik/spark-runtime:$IMAGE_TAG docker/runtime/spark
fi
if [ $BUILD_SPARK_NATIVE_SQL ] || [ $BUILD_ALL ]; then
docker build $NO_CACHE --build-arg BASE_IMAGE=$IMAGE_TAG -t cloudtik/spark-native-sql:$IMAGE_TAG docker/runtime/spark/native-sql
fi
if [ $BUILD_SPARK_OPTIMIZED ] || [ $BUILD_ALL ]; then
docker build $NO_CACHE --build-arg BASE_IMAGE=$IMAGE_TAG -t cloudtik/spark-optimized:$IMAGE_TAG docker/runtime/spark/optimized
fi
if [ $BUILD_UNIVERSE ] || [ $BUILD_ALL ]; then
docker build $NO_CACHE --build-arg BASE_IMAGE=$IMAGE_TAG -t cloudtik/universe-runtime:$IMAGE_TAG docker/runtime/universe
fi
if [ $BUILD_PRESTO ] || [ $BUILD_ALL ]; then
docker build $NO_CACHE --build-arg BASE_IMAGE=$IMAGE_TAG -t cloudtik/presto-runtime:$IMAGE_TAG docker/runtime/presto
fi
if [ $BUILD_TRINO ] || [ $BUILD_ALL ]; then
docker build $NO_CACHE --build-arg BASE_IMAGE=$IMAGE_TAG -t cloudtik/trino-runtime:$IMAGE_TAG docker/runtime/trino
fi
if [ $BUILD_ML ] || [ $BUILD_ALL ]; then
docker build $NO_CACHE --build-arg BASE_IMAGE=$IMAGE_TAG -t cloudtik/spark-ml-runtime:$IMAGE_TAG docker/runtime/ml
fi
if [ $BUILD_SPARK_BENCHMARK ] || [ $BUILD_ALL ]; then
docker build $NO_CACHE --build-arg BASE_IMAGE=$IMAGE_TAG -t cloudtik/spark-runtime-benchmark:$IMAGE_TAG docker/runtime/spark/benchmark
fi
if [ $BUILD_SPARK_NATIVE_SQL_BENCHMARK ] || [ $BUILD_ALL ]; then
docker build $NO_CACHE --build-arg BASE_IMAGE=$IMAGE_TAG -t cloudtik/spark-native-sql-benchmark:$IMAGE_TAG docker/runtime/spark/benchmark/native-sql
fi
if [ $BUILD_SPARK_OPTIMIZED_BENCHMARK ] || [ $BUILD_ALL ]; then
docker build $NO_CACHE --build-arg BASE_IMAGE=$IMAGE_TAG -t cloudtik/spark-optimized-benchmark:$IMAGE_TAG docker/runtime/spark/benchmark/optimized
fi