-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_env
executable file
·50 lines (44 loc) · 1.47 KB
/
build_env
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
#!/usr/bin/env bash
version='0.0.1'
# make sure login docker registry
#docker login docker.clounix.com
# check docker image for building
if [ "$(docker images -q onie-build-env:$version 2> /dev/null)" == "" ]; then
echo "Build Docker image as onie-build-env:$version"
docker image build --compress -t onie-build-env:$version -f ./contrib/build-env/Dockerfile .
fi
if [ "$(docker images -q onie-build-env-$USER:$version 2> /dev/null)" == "" ]; then
echo "Build Docker image as onie-build-env-$USER:$version"
docker image build \
--build-arg version=$version \
--build-arg user=$USER \
--build-arg uid=$(id -u) \
--build-arg guid=$(id -g) \
--build-arg homedir=/home/$USER \
--build-arg hostname=$HOSTNAME \
-t onie-build-env-$USER:$version \
-f ./contrib/build-env/Dockerfile.user \
.
fi
# work-around for Jenckins pipeline
test -t 1 && USE_TTY="-t"
# execute commands
if [ $# -ne 0 ]; then
echo "$@ ..."
docker run \
-v /home/$USER:/home/$USER \
-v `pwd`:`pwd` \
-w `pwd`/build-config \
--cap-add=NET_ADMIN \
--cap-add=MKNOD \
-i $USE_TTY --rm --network host onie-build-env-$USER:$version $@
else
echo "Start bash ..."
docker run \
-v /home/$USER:/home/$USER \
-v `pwd`:`pwd` \
-w `pwd`/build-config \
--cap-add=NET_ADMIN \
--cap-add=MKNOD \
-i $USE_TTY --rm --network host onie-build-env-$USER:$version bash
fi