forked from iot-salzburg/gpu-jupyter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_push_all.sh
executable file
·58 lines (45 loc) · 2.3 KB
/
build_push_all.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
#!/usr/bin/env bash
cd $(cd -P -- "$(dirname -- "$0")" && pwd -P)
# extract the branch-name that is built and pushed
export TAGNAME=$(git symbolic-ref -q HEAD)
export TAGNAME=${TAGNAME##refs/heads/}
export TAGNAME=${TAGNAME:-HEAD}
# manually set tag
# export TAGNAME="v1.5_cuda-11.6_ubuntu-20.04"
echo "Build and push images full, python-only & slim for branch '$TAGNAME'."
if [[ "$TAGNAME" != "v"*"_cuda-"*"_ubuntu-"* ]]; then
echo "ERROR, build_push_all.sh only possible within branches of shape 'v'*'_cuda-'*'_ubuntu-'*."
exit 1
fi
###################### build, run and push full image ##########################
echo
echo
echo "build, run and push full image with tag $TAGNAME."
bash generate-Dockerfile.sh
docker build --no-cache -t cschranz/gpu-jupyter:$TAGNAME .build/ # build this from a fresh install
export IMG_ID=$(docker image ls | grep $TAGNAME | grep -v _python-only | grep -v _slim | head -1 | awk '{print $3}')
echo "push image with ID $IMG_ID and Tag $TAGNAME ."
docker tag $IMG_ID cschranz/gpu-jupyter:$TAGNAME
docker rm -f gpu-jupyter_1
docker run --gpus all -d -it -p 8848:8888 -v $(pwd)/data:/home/jovyan/work -e GRANT_SUDO=yes -e JUPYTER_ENABLE_LAB=yes --user root --restart always --name gpu-jupyter_1 cschranz/gpu-jupyter:$TAGNAME
docker push cschranz/gpu-jupyter:$TAGNAME
###################### build and push slim image ##########################
echo
echo
echo "build and push slim image with tag ${TAGNAME}_slim."
bash generate-Dockerfile.sh --slim
docker build -t cschranz/gpu-jupyter:${TAGNAME}_slim .build/
export IMG_ID=$(docker image ls | grep ${TAGNAME}_slim | head -1 | awk '{print $3}')
echo "push image with ID $IMG_ID and Tag ${TAGNAME}_slim."
docker tag $IMG_ID cschranz/gpu-jupyter:${TAGNAME}_slim
docker push cschranz/gpu-jupyter:${TAGNAME}_slim
###################### build and push python-only image ##########################
echo
echo
echo "build and push slim image with tag ${TAGNAME}_python-only."
bash generate-Dockerfile.sh --python-only
docker build -t cschranz/gpu-jupyter:${TAGNAME}_python-only .build/
export IMG_ID=$(docker image ls | grep ${TAGNAME}_python-only | head -1 | awk '{print $3}')
echo "push image with ID $IMG_ID and Tag ${TAGNAME}_python-only."
docker tag $IMG_ID cschranz/gpu-jupyter:${TAGNAME}_python-only
docker push cschranz/gpu-jupyter:${TAGNAME}_python-only