]> git.localhorst.tv Git - blobs.git/blob - scripts/docker/exec.bash
stolen dockerfiles from blank
[blobs.git] / scripts / docker / exec.bash
1 #!/bin/bash
2
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 #   KEEP:     file names to copy back out after all TARGETS have run
8
9 IMAGE="${IMAGE:-archlinux-build}"
10
11 image_name="localhorsttv/${IMAGE}"
12 image_path="scripts/docker/${IMAGE//:/-}"
13
14 xvfb_cmd="xvfb-run -a --server-args='-screen 0 1024x768x24 +extension RANDR +extension GLX'"
15
16 build_cmd="cp -R /repo /workdir && cd /workdir && make -j\$(nproc) $TARGETS"
17
18 if [[ "$KEEP" != "" ]]; then
19         build_cmd="${build_cmd} && cp -Rv $KEEP /repo"
20 fi
21
22
23 local_conf=""
24
25 if [[ "$TARGETS" == *codecov* ]]; then
26         local_conf="$local_conf $(bash <(curl -s https://codecov.io/env))"
27 fi
28
29 docker build -t "${image_name}" --pull=true "${image_path}"
30 docker run -v "$PWD":/repo ${local_conf} "${image_name}" sh -c "$xvfb_cmd sh -c '${build_cmd}'"