From 9a88f5876c63b07655c9944e51dec7086ce64e96 Mon Sep 17 00:00:00 2001 From: Jean Baptiste Favre Date: Tue, 28 Jun 2016 17:12:25 +0200 Subject: [PATCH] Finalize docker image for SelfOSS 2.15 --- Dockerfile | 6 ++++-- docker-entrypoint.sh | 31 +++++++++++++++++++++++++++++-- run.php | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 4 deletions(-) mode change 100644 => 100755 docker-entrypoint.sh create mode 100644 run.php diff --git a/Dockerfile b/Dockerfile index bfb2607..b56a3d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,8 @@ RUN /usr/bin/apt-get update -yqq \ && /usr/bin/curl -L -o /tmp/selfoss.tar.gz https://github.com/SSilence/selfoss/archive/2.15.tar.gz RUN /bin/su - selfoss -c '/bin/tar xzf /tmp/selfoss.tar.gz -C /home/selfoss --strip-components=1' \ - && /bin/rm /tmp/selfoss.tar.gz \ + && /bin/rm -f /tmp/selfoss.tar.gz \ + && /bin/rm -f /home/selfoss/selfoss*.zip \ && /bin/mkdir /var/lib/selfoss \ && /bin/chown -R selfoss: /var/lib/selfoss \ && /bin/bash /tmp/debian_cleaner.sh @@ -27,5 +28,6 @@ RUN /bin/su - selfoss -c '/bin/tar xzf /tmp/selfoss.tar.gz -C /home/selfoss --st VOLUME /var/lib/selfoss ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] ADD ./docker-entrypoint.sh /usr/local/bin +ADD ./run.php /home/selfoss/ -EXPOSE 80 +EXPOSE 8080 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh old mode 100644 new mode 100755 index ae2dd8c..16fd864 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -5,10 +5,37 @@ SELFOSSDATA=/var/lib/selfoss SELFOSSPROG=/home/selfoss function setup_selfoss() { + /bin/mv ${SELFOSSPROG}/data ${SELFOSSDATA}/ + /bin/ln -s ${SELFOSSDATA}/data ${SELFOSSPROG}/ + /bin/mv ${SELFOSSPROG}/public ${SELFOSSDATA}/ + /bin/ln -s ${SELFOSSDATA}/public ${SELFOSSPROG}/ } -trap "shut_down" SIGKILL SIGTERM SIGHUP SIGINT EXIT +function update_selfoss() { + /bin/rm -rf ${SELFOSSPROG}/data + /bin/ln -s ${SELFOSSDATA}/data ${SELFOSSPROG}/ + /bin/rm -rf ${SELFOSSPROG}/public + /bin/ln -s ${SELFOSSDATA}/public ${SELFOSSPROG}/ + /bin/rm -f ${SELFOSSPROG}/public/all* +} + +function config_selfoss() { + /bin/sed -i 's/^logger_level=.*$/logger_level=DEBUG/' ${SELFOSSPROG}/defaults.ini + /bin/sed -i 's/^homepage=.*$/homepage=unread/' ${SELFOSSPROG}/defaults.ini +} +#trap "shut_down" SIGKILL SIGTERM SIGHUP SIGINT EXIT /bin/chown selfoss:selfoss ${SELFOSSDATA} -/bin/su - selfoss -c 'php -S 0.0.0.0:8080 -t /home/selfoss' +if [ ! -f ${SELFOSSDATA}/data/sqlite/selfoss.db ] +then + echo "* Setting up SelfOSS" + setup_selfoss +else + echo "* Updating SelfOSS" + update_selfoss +fi +echo "** Configuring SelfOSS" +config_selfoss + +/bin/su - selfoss -c "TERM=xterm /usr/bin/php -S 0.0.0.0:8080 -t ${SELFOSSPROG} ${SELFOSSPROG}/run.php" diff --git a/run.php b/run.php new file mode 100644 index 0000000..93b7d4e --- /dev/null +++ b/run.php @@ -0,0 +1,35 @@ +