-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_container.sh
executable file
·41 lines (35 loc) · 1.05 KB
/
run_container.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
#!/bin/bash
RUN_ARGS=()
BUILD_NO_CACHE=""
for ARG in "$@"; do
case $ARG in
--host-build-dir=*)
BUILD_FOLDER_NAME=${ARG#*=}
;;
--docker-no-cache*)
BUILD_NO_CACHE="--no-cache"
;;
--docker-shm-size*)
DOCKER_SHM_SIZE="${ARG#*=}"
;;
*)
RUN_ARGS+=("$ARG")
;;
esac
done
if [ -z "$BUILD_FOLDER_NAME" ]; then
echo -e "\e[1;33mHost build dir is not provided, using 'build_vm_image' dir\e[0m"
BUILD_FOLDER_NAME=build_vm_image/
fi
if ! [ "$DOCKER_SHM_SIZE" ]; then
DOCKER_SHM_SIZE="1024m";
fi
BUILD_PATH="$PWD"/"$BUILD_FOLDER_NAME"
mkdir -p "$BUILD_FOLDER_NAME"
docker build . --build-arg user_id="$(id -u)" -t yocto $BUILD_NO_CACHE
docker run -it --rm -p 7001:7001 -p 7002:7002 -p 8001:8001 -p 8002:8002 \
--shm-size="$DOCKER_SHM_SIZE" \
-v "$BUILD_PATH":/home/user/project/build_dir \
-v "$PWD"/qemu_src:/home/user/project/qemu_src \
-v "$PWD"/yocto_files:/home/user/project/yocto_files \
yocto "${RUN_ARGS[@]}"