Finalize docker image for SelfOSS 2.15
This commit is contained in:
parent
2eac287011
commit
9a88f5876c
@ -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
|
||||
|
31
docker-entrypoint.sh
Normal file → Executable file
31
docker-entrypoint.sh
Normal file → Executable file
@ -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"
|
||||
|
35
run.php
Normal file
35
run.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
// Only run this if running from php 5.4 embedded server
|
||||
if (php_sapi_name() == 'cli-server') {
|
||||
|
||||
if ( preg_match( '/\.(?:js|ico|gif|jpg|png|css|asc|txt|eot|woff|ttf|ttf|svg)$/', $_SERVER["REQUEST_URI"] ) ) {
|
||||
|
||||
// serves fronted
|
||||
if ( preg_match( '/^\/public/', $_SERVER["REQUEST_URI"] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// serves favicons
|
||||
if ( preg_match( '/^\/data/', $_SERVER["REQUEST_URI"] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//redirects to proper location for favicons
|
||||
if ( preg_match( '/(favicons|thumbnails)/', $_SERVER["REQUEST_URI"] ) ) {
|
||||
header( "Location: /data".$_SERVER["REQUEST_URI"] );
|
||||
exit;
|
||||
}
|
||||
|
||||
//redirects to proper location for frontend
|
||||
header( "Location: /public".$_SERVER["REQUEST_URI"] );
|
||||
exit;
|
||||
|
||||
} else {
|
||||
// taken from cli arg, hack for updater
|
||||
$_SERVER["SERVER_ADDR"] = '127.0.0.1';
|
||||
$_SERVER["SERVER_NAME"] = '127.0.0.1';
|
||||
require("index.php");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user