]> git.localhorst.tv Git - blank.git/blob - scripts/docker/exec.bash
faabff467b259a617162922154a933385ae6f879
[blank.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 #   PASS_ENV: names of environment variables to import into
8 #             the container during build
9
10 IMAGE="${IMAGE:-archlinux-build}"
11
12 image_name="localhorsttv/${IMAGE}"
13 image_path="scripts/docker/${IMAGE//:/-}"
14
15 build_cmd="cd /repo && make -j\$(nproc) $TARGETS"
16
17 local_conf=""
18
19 if [[ "$TARGETS" == *codecov* ]]; then
20         local_conf="$local_conf $(bash <(curl -s https://codecov.io/env))"
21 fi
22
23 if [ -e "${image_path}/env" ]; then
24         local_conf="$local_conf --env-file ${image_path}/env"
25 fi
26
27 # copy XDG_RUNTIME_DIR if set
28 if [ "$XDG_RUNTIME_DIR" != "" ]; then
29         local_conf="$local_conf -e XDG_RUNTIME_DIR='$XDG_RUNTIME_DIR'"
30 fi
31
32 docker build -t "${image_name}" --pull=true "${image_path}"
33 docker run -v "$PWD":/repo ${local_conf} "${image_name}" xvfb-run --server-args="-screen 0 1024x768x24" bash -c "env ; glewinfo | head ; ${build_cmd}"