-
Notifications
You must be signed in to change notification settings - Fork 31
/
docker-build.sh
executable file
·24 lines (20 loc) · 1.03 KB
/
docker-build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
DOCKER_IMG_NAME=phoenixrtos/build
if [ -e .docker_build_img ]; then
DOCKER_IMG_NAME="$(cat .docker_build_img)"
fi
PATH_TO_PROJECT="$(dirname "$(realpath "${BASH_SOURCE[0]}")")/"
DOCKER_USER="$(id -u):$(id -g)"
TMPFS_OVERLAY=()
if [ "$(uname)" = "Darwin" ]; then
# I/O operations on bind mounts in Darwin are painfully slow - use tmpfs for intermediate build artifacts
chmod 777 "_build" # fix against invalid tmpfs permissions
TMPFS_OVERLAY=("--tmpfs" "/src/_build:exec")
fi
if [ "$#" -eq 1 ] && [ "$1" = "bash" ]; then
# run interactive shell - using ROOT user
exec docker run -it --rm -v "${PATH_TO_PROJECT}:/src" -w /src -e TARGET -e SYSPAGE -e CONSOLE -e LONG_TEST -e SIL -e DEBUG --entrypoint bash "$DOCKER_IMG_NAME"
else
# run build - use our own UID/GID to create files with correct owner
exec docker run -it --user "$DOCKER_USER" --rm -v "${PATH_TO_PROJECT}:/src:delegated" -w /src "${TMPFS_OVERLAY[@]}" -e TARGET -e SYSPAGE -e CONSOLE -e LONG_TEST -e SIL -e DEBUG "$DOCKER_IMG_NAME" "$@"
fi