TeaWeb/scripts/run_node_docker.sh

29 lines
705 B
Bash
Raw Permalink Normal View History

2023-11-21 14:32:34 +00:00
#!/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 docker -v | grep -qi "podman"; then
is_podman='yes'
fi
function run() {
docker run --rm --workdir "/work" -v "${BASEPATH}:/work" -e is_podman="${is_podman:-no}" -e BUILDINDOCKER=yes -e npm_config_cache=/work/.npm ${opts:-} node:14-bullseye ${@}
}
opts="-it" run /bin/bash -c 'bash /work/scripts/in_docker_prep.sh && bash'
if [[ "${is_podman}" != 'yes' ]]; then
echo "fixing perms"
run /bin/bash -c 'chown -R 1000:1000 /work'
else
echo "in podman, not fixing perms"
fi