]> git.localhorst.tv Git - blobs.git/blobdiff - scripts/docker/exec.bash
stolen dockerfiles from blank
[blobs.git] / scripts / docker / exec.bash
index 9874c9a9f49fbe0b4db2d0d06e790f557eeb89b6..ea6f97daa93e1825dcaeeca1616ca9cafb38953e 100755 (executable)
@@ -4,15 +4,21 @@
 # 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//:/-}"
 
-build_cmd="cd /repo && make -j\$(nproc) $TARGETS"
+xvfb_cmd="xvfb-run -a --server-args='-screen 0 1024x768x24 +extension RANDR +extension GLX'"
+
+build_cmd="cp -R /repo /workdir && cd /workdir && make -j\$(nproc) $TARGETS"
+
+if [[ "$KEEP" != "" ]]; then
+       build_cmd="${build_cmd} && cp -Rv $KEEP /repo"
+fi
+
 
 local_conf=""
 
@@ -20,9 +26,5 @@ if [[ "$TARGETS" == *codecov* ]]; then
        local_conf="$local_conf $(bash <(curl -s https://codecov.io/env))"
 fi
 
-if [ -e "${image_path}/env" ]; then
-       local_conf="$local_conf --env-file ${image_path}/env"
-fi
-
 docker build -t "${image_name}" --pull=true "${image_path}"
-docker run -v "$PWD":/repo ${local_conf} "${image_name}" /bin/bash -c "${build_cmd}"
+docker run -v "$PWD":/repo ${local_conf} "${image_name}" sh -c "$xvfb_cmd sh -c '${build_cmd}'"