
Optionally run as another user/group only if the env vars are specified. Should give flexibility to those who need to run processes as root and open ports without having to request additional priveleges
32 lines
972 B
Text
Executable file
32 lines
972 B
Text
Executable file
#!/command/with-contenv bash
|
|
# shellcheck shell=bash
|
|
|
|
set -e
|
|
|
|
. /bin/common.sh
|
|
|
|
cd /app || exit 1
|
|
|
|
if [ "${DEVELOPMENT:-}" = "true" ]; then
|
|
if [ "$PUID" = '0' ]; then
|
|
log_info 'Starting backend development ...'
|
|
yarn install
|
|
node --max_old_space_size=250 --abort_on_uncaught_exception node_modules/nodemon/bin/nodemon.js
|
|
else
|
|
log_info "Starting backend development as npmuser ($PUID) ..."
|
|
s6-setuidgid npmuser yarn install
|
|
exec s6-setuidgid npmuser bash -c 'export HOME=/tmp/npmuserhome;node --max_old_space_size=250 --abort_on_uncaught_exception node_modules/nodemon/bin/nodemon.js'
|
|
fi
|
|
else
|
|
while :
|
|
do
|
|
if [ "$PUID" = '0' ]; then
|
|
log_info 'Starting backend ...'
|
|
node --abort_on_uncaught_exception --max_old_space_size=250 index.js
|
|
else
|
|
log_info "Starting backend as npmuser ($PUID) ..."
|
|
s6-setuidgid npmuser bash -c 'export HOME=/tmp/npmuserhome;node --abort_on_uncaught_exception --max_old_space_size=250 index.js'
|
|
fi
|
|
sleep 1
|
|
done
|
|
fi
|