]> git.localhorst.tv Git - blank.git/blobdiff - scripts/docker/exec.bash
git is a "runtime" dependency
[blank.git] / scripts / docker / exec.bash
index b146e7647e712ac85e767f08502776a8736614b1..3ba2d6f44420e43b0e7b719b2b3953930c3af850 100755 (executable)
@@ -4,14 +4,27 @@
 # environment varables:
 #   IMAGE:    name of the docker image to use
 #   TARGETS:  targets to pass to `make` inside the container
-#   PASS_ENV: names of environment variables to import into
-#             the container during build
+#   KEEP:     file names to copy back out after all TARGETS have run
 
 IMAGE="${IMAGE:-archlinux-build}"
 
+image_name="localhorsttv/${IMAGE}"
+image_path="scripts/docker/${IMAGE//:/-}"
+
+xvfb_cmd="xvfb-run -a --server-args='-screen 0 1024x768x24 +extension RANDR +extension GLX'"
+
+build_cmd="git clone /repo /workdir && cd /workdir && make -j\$(nproc) $TARGETS"
+
+if [[ "$KEEP" != "" ]]; then
+       build_cmd="${build_cmd} && cp -Rv $KEEP /repo"
+fi
+
+
+local_conf=""
+
 if [[ "$TARGETS" == *codecov* ]]; then
-       ci_env=`bash <(curl -s https://codecov.io/env)`
+       local_conf="$local_conf $(bash <(curl -s https://codecov.io/env))"
 fi
 
-docker build -t "blank/${IMAGE}" scripts/docker/"${IMAGE}"
-docker run -v "$PWD":/repo ${ci_env} "blank/${IMAGE}" /bin/bash -c "cd /repo && make -j\$(nproc) $TARGETS"
+docker build -t "${image_name}" --pull=true "${image_path}"
+docker run -v "$PWD":/repo ${local_conf} "${image_name}" sh -c "$xvfb_cmd sh -c '${build_cmd}'"