added support for docker to run with a certain PUID and PGID

This commit is contained in:
JJ Kasper
2018-09-22 12:27:45 -05:00
parent 56f9ee318f
commit b47f3917bd
3 changed files with 32 additions and 15 deletions

View File

@@ -1,25 +1,40 @@
#!/bin/bash
PKGDIR="/opt/mykb"
DBDIR="$PKGDIR/db"
KBDIR="$PKGDIR/kb"
CONFDIR="$PKGDIR/config"
if [ -d "/db" ];then
rm -rf /opt/mykb/db
ln -s /db /opt/mykb/db
rm -rf $DBDIR
ln -s /db $DBDIR
DBDIR="/db"
fi
if [ -d "/kb" ];then
rm -rf /opt/mykb/kb
ln -s /kb /opt/mykb/kb
KBDIR="/kb"
fi
if [ -d "/config" ];then
for i in /opt/mykb/config/*;do file=${i#/opt/mykb/config/}; if [ ! -f "/config/$file" ];then cp "$i" "/config/$file"; fi;done
rm -rf /opt/mykb/config
ln -s /config /opt/mykb/config
for i in $CONFDIR/*;do file=${i#/opt/mykb/config/}; if [ ! -f "/config/$file" ];then cp "$i" "/config/$file"; fi;done
rm -rf $CONFDIR
ln -s /config $CONFDIR
CONFDIR="/config"
fi
git config --global user.email "$GIT_EMAIL"
git config --global user.name "$GIT_NAME"
cd /opt/mykb
echo $PWD
NODE_ENV=production node ./genSecret.js
yarn start
export NODE_ENV=production
if [ -z "$PUID" ];then
echo 'no PUID set running as default user'
node ./genSecret.js && node ./src
else
echo 'chowning files'
DIRS=($KBDIR $DBDIR $CONFDIR)
for dir in ${DIRS[@]};do chown "$PUID:$PGID" $dir;done
chown "$PUID:$PGID" -R $CONFDIR
s6-setuidgid "$PUID:$PGID" node ./genSecret.js
s6-setuidgid "$PUID:$PGID" node ./src
fi