diff --git a/package-lock.json b/package-lock.json index dd760333..f158b4db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23898,4 +23898,4 @@ } } } -} \ No newline at end of file +} diff --git a/scripts/build_in_docker.sh b/scripts/build_in_docker.sh index 5d79ed5e..45d5e39e 100755 --- a/scripts/build_in_docker.sh +++ b/scripts/build_in_docker.sh @@ -11,20 +11,17 @@ if [[ ! -d "${NPM_DIR}" ]]; then fi if [[ "${BUILDINDOCKER:-}" != "yes" ]]; then - docker run --rm --workdir "/work" -v "${NPM_DIR}:/home/" -v "${BASEPATH}:/work" -e BUILDINDOCKER=yes node:14-bullseye /bin/bash -c 'chmod +x /work/scripts/build_in_docker.sh && /work/scripts/build_in_docker.sh' + 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 npmrc" -cat >>"${HOME}/.npmrc" <<'EOF' -cache=/work/.npm -fund=false -EOF - echo "adding secure git dir" -git config --global --add safe.directory /work +git config --global --add safe.directory '*' echo "running chmods" find "${BASEPATH}" -iname "*.sh" -exec chmod +x {} + @@ -41,5 +38,9 @@ npx browserslist@latest --update-db || exit 1 echo "running build" "${BASEPATH}/scripts/build.sh" web rel -echo "fixing perms" -chown -R 1000:1000 /work +if [[ "${is_podman}" != 'yes' ]]; then + echo "fixing perms" + chown -R 1000:1000 /work +else + echo "in podman, not fixing perms" +fi diff --git a/scripts/in_docker_prep.sh b/scripts/in_docker_prep.sh new file mode 100755 index 00000000..86f2a3c9 --- /dev/null +++ b/scripts/in_docker_prep.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +SCRIPT=$(realpath "$0") +SCRIPTPATH=$(dirname "$SCRIPT") +BASEPATH="$(realpath "${SCRIPTPATH}/../")" + +echo "adding secure git dir" +git config --global --add safe.directory '*' + +echo "running chmods" +find "${BASEPATH}" -iname "*.sh" -exec chmod +x {} + diff --git a/scripts/run_node_docker.sh b/scripts/run_node_docker.sh new file mode 100755 index 00000000..14e89f0a --- /dev/null +++ b/scripts/run_node_docker.sh @@ -0,0 +1,28 @@ +#!/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