3 # execute from project root
4 # environment varables:
5 # IMAGE: name of the docker image to use
6 # TARGETS: targets to pass to `make` inside the container
7 # PASS_ENV: names of environment variables to import into
8 # the container during build
10 IMAGE="${IMAGE:-archlinux-build}"
12 image_name="localhorsttv/${IMAGE}"
13 image_path="scripts/docker/${IMAGE//:/-}"
15 build_cmd="cd /repo && make -j\$(nproc) $TARGETS"
19 if [[ "$TARGETS" == *codecov* ]]; then
20 local_conf="$local_conf $(bash <(curl -s https://codecov.io/env))"
23 if [ -e "${image_path}/env" ]; then
24 local_conf="$local_conf --env-file ${image_path}/env"
28 if [ "$DISPLAY" != "" ]; then
29 local_conf="$local_conf -e DISPLAY=$DISPLAY"
32 # copy XDG_RUNTIME_DIR if set
33 if [ "$XDG_RUNTIME_DIR" != "" ]; then
34 local_conf="$local_conf -e XDG_RUNTIME_DIR='$XDG_RUNTIME_DIR'"
37 docker build -t "${image_name}" --pull=true "${image_path}"
38 docker run -v "$PWD":/repo ${local_conf} "${image_name}" /bin/bash -c "env && ${build_cmd}"