mirror of
https://github.com/proot-me/proot.git
synced 2025-08-28 16:43:49 +02:00
* Make sure we actually check if `img` is available The current logic checks if docker is available a second time if it is available and set the builder to img without checking if docker isn't available. * Check if docker can run hello-world to catch permission error for the running user.
34 lines
654 B
Bash
34 lines
654 B
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
# Test can run using either builder
|
|
BUILDER="docker"
|
|
if [ -z "$(command -v ${BUILDER})" ] || ! docker run hello-world > /dev/null 2>&1; then
|
|
BUILDER="img"
|
|
if [ -z "$(command -v ${BUILDER})" ]; then
|
|
exit 125
|
|
fi
|
|
fi
|
|
|
|
# Export for use in subshell
|
|
export BUILDER
|
|
export DOCKER_IMAGE="proot-me/proot"
|
|
|
|
TMP=$(mcookie)
|
|
TMP="/tmp/${TMP}"
|
|
|
|
# Generate image list
|
|
find . -name 'Dockerfile' -exec sh -c '
|
|
TAG=$(echo "${1}" | ../util/parse-docker-tag.awk)
|
|
echo ${BUILDER} build -t ${DOCKER_IMAGE}:${TAG} -f ${1} ..
|
|
' sh {} \; | sort -k1 > "${TMP}"
|
|
|
|
cat "${TMP}"
|
|
|
|
# Build all images
|
|
sh "${TMP}"
|
|
|
|
rm "${TMP}"
|
|
|
|
unset BUILDER
|
|
|