-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-img.sh
executable file
·31 lines (25 loc) · 913 Bytes
/
build-img.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
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
set -o xtrace
ROOT=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd -P)
IMAGE_FILE=${IMAGE_FILE:-"registry-dev.xcloud.lenovo.com:18083/earth_system/vcuda:12.2.0"}
function cleanup() {
rm -rf ${ROOT}/cuda-control.tar
}
trap cleanup EXIT SIGTERM SIGINT
function build_img() {
readonly local commit=$(git log --oneline | wc -l | sed -e 's,^[ \t]*,,')
readonly local version=$(<"${ROOT}/VERSION")
rm -rf ${ROOT}/build
mkdir ${ROOT}/build
git archive -o ${ROOT}/build/cuda-control.tar --format=tar --prefix=cuda-control/ HEAD
cp ${ROOT}/vcuda.spec ${ROOT}/build
cp ${ROOT}/Dockerfile ${ROOT}/build
(
cd ${ROOT}/build
docker build ${BUILD_FLAGS:-} -f Dockerfile --build-arg version=${version} --build-arg commit=${commit} -t ${IMAGE_FILE} --platform=linux/amd64 --progress=plain -o type=docker .
)
}
build_img