Files
docker/build.sh
2025-10-31 22:49:08 -06:00

38 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
HERE=$(dirname "$(realpath "${0}")")
ANDROID_TARGETS="mainline optimized legacy"
LINUX_TARGETS="native amd64 steamdeck zen2 allyx rog-ally zen4 legacy aarch64 armv9"
if [[ "${#}" != 2 ]]; then
echo "${0} <android|linux> <${ANDROID_TARGETS// /|}|${LINUX_TARGETS// /|}>"
exit 1
fi
# Now we know ${1} isn't unbound
IMAGE="eden-${1}-builder"
if [[ "${1}" == "android" ]]; then
if [[ "$(grep " ${2} " <<< " ${ANDROID_TARGETS} ")" == "" ]]; then
echo "Android target must be one of: ${ANDROID_TARGETS}"
exit 1
fi
elif [[ "${1}" == "linux" ]]; then
if [[ "$(grep " ${2} " <<< " ${LINUX_TARGETS} ")" == "" ]]; then
echo "Linux target must be one of: ${LINUX_TARGETS}"
exit 1
fi
else
echo "Platform must be one of: android linux"
exit 1
fi
if [[ "$(docker images | grep "^${IMAGE} ")" == "" ]]; then
docker pull ubuntu
docker build --no-cache -t "${IMAGE}" -f "${HERE}/Dockerfile.${1}" "${HERE}"
fi
docker run --rm -v "${HERE}/eden":/source -v "${HERE}":/output "${IMAGE}" "${2}"