added support for docker to run with a certain PUID and PGID
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
FROM node:8-alpine
|
||||
|
||||
RUN apk add yarn git bash
|
||||
RUN apk add yarn git bash s6
|
||||
RUN mkdir -p /opt/mykb
|
||||
|
||||
# install node_modules to tmp so it can be cached
|
||||
@@ -15,13 +15,13 @@ RUN cd /opt/mykb && yarn build
|
||||
COPY docker_startup.sh /mykb
|
||||
RUN chmod +x /mykb
|
||||
|
||||
VOLUME /kb
|
||||
VOLUME /db
|
||||
VOLUME /config
|
||||
VOLUME /kb /db /config
|
||||
|
||||
EXPOSE 3030
|
||||
|
||||
ARG GIT_NAME=mykb
|
||||
ARG GIT_EMAIL=mykb@localhost
|
||||
ARG PUID
|
||||
ARG PGID
|
||||
|
||||
CMD [ "/mykb" ]
|
||||
@@ -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
|
||||
@@ -22,6 +22,8 @@ class Service {
|
||||
fs.stat(path.join(this.docsDir, '.git'), async err => {
|
||||
if (err && err.code === 'ENOENT') {
|
||||
git.init().then(() => {
|
||||
git.addConfig('user.name', 'mykb')
|
||||
git.addConfig('user.email', 'mykb@localhost')
|
||||
if (this.numInitDocs === 0) return
|
||||
git.add('./*').then(() => git.commit('initial commit'))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user