TeaWeb/scripts/build_in_docker.sh

47 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
SCRIPT=$(realpath "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
BASEPATH="$(realpath "${SCRIPTPATH}/../")"
NPM_DIR="${BASEPATH}/.npm"
if [[ ! -d "${NPM_DIR}" ]]; then
mkdir "${NPM_DIR}" || exit 1
fi
if [[ "${BUILDINDOCKER:-}" != "yes" ]]; then
if docker -v | grep -qi "podman"; then
is_podman='yes'
fi
docker run --rm --workdir "/work" -v "${BASEPATH}:/work" -e is_podman="${is_podman:-no}" -e BUILDINDOCKER=yes -e npm_config_cache=/work/.npm node:14-bullseye /bin/bash -c 'chmod +x /work/scripts/build_in_docker.sh && /work/scripts/build_in_docker.sh'
exit
fi
## in docker
echo "adding secure git dir"
git config --global --add safe.directory '*'
echo "running chmods"
find "${BASEPATH}" -iname "*.sh" -exec chmod +x {} +
echo "Cleaning up old files"
"${BASEPATH}/scripts/cleanup.sh" full >/dev/null 2>&1 || exit 1
echo "Installing npm packages"
npm i || exit 1
echo "Updating browser list"
npx browserslist@latest --update-db || exit 1
echo "running build"
"${BASEPATH}/scripts/build.sh" web rel
if [[ "${is_podman}" != 'yes' ]]; then
echo "fixing perms"
chown -R 1000:1000 /work
else
echo "in podman, not fixing perms"
fi