From eb9f261070643dd0cc05aa5b77952105fa6c487f Mon Sep 17 00:00:00 2001 From: Jeroen Geusebroek Date: Sun, 17 Jan 2016 21:53:50 +0100 Subject: [PATCH] Initial Commit --- .dockerignore | 11 ++++++++++ .gitignore | 13 +++++++++++ Dockerfile | 37 +++++++++++++++++++++++++++++++ README.md | 11 ++++++++++ build.sh | 2 ++ buildNoCache.sh | 2 ++ entrypoint.sh | 49 ++++++++++++++++++++++++++++++++++++++++++ files/000-default.conf | 15 +++++++++++++ 8 files changed, 140 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 README.md create mode 100755 build.sh create mode 100755 buildNoCache.sh create mode 100644 entrypoint.sh create mode 100644 files/000-default.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6dae2b5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +# Git files +.git +.gitignore + +#build files +build.sh +buildNoCache.sh + +# Information files +LICENSE +README.md \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a084c4d --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# Created by .gitignore support plugin (hsz.mobi) +.idea +*.iml + +# OSX +.DS_Store +.AppleDouble +.LSOverride + +# Linux +*~ +.directory +.Trash-* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3a5c490 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +FROM ubuntu:15.10 +MAINTAINER Jeroen Geusebroek + +ENV DEBIAN_FRONTEND="noninteractive" \ + TERM="xterm" \ + APTLIST="apache2 php5 php5-curl php5-gd php5-gmp php5-mysql git-core sudo cron" \ + REFRESHED_AT='2015-01-18' + +RUN echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup &&\ + echo "Acquire::http {No-Cache=True;};" > /etc/apt/apt.conf.d/no-cache && \ + apt-get -q update && \ + apt-get -qy --force-yes dist-upgrade && \ + apt-get install -qy --force-yes $APTLIST && \ + + # Cleanup + apt-get -y autoremove && \ + apt-get -y clean && \ + rm -rf /var/lib/apt/lists/* && \ + rm -r /var/www/html && \ + rm -rf /tmp/* + +RUN git clone https://github.com/spotweb/spotweb.git /var/www/spotweb && \ + cd /var/www/spotweb && \ + git checkout media && \ + chmod -R 775 /var/www/spotweb && \ + chown -R www-data:www-data /var/www/spotweb + +COPY ./entrypoint.sh /entrypoint.sh +RUN chmod u+x /entrypoint.sh + +COPY files/000-default.conf /etc/apache2/sites-enabled/000-default.conf + +VOLUME [ "/config" ] + +EXPOSE 80 + +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e8df47f --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Docker spotweb + docker run --restart=always -d -p 80:80 \ + --hostname=spotweb \ + --name=spotweb \ + -v /config:/config \ + -e SPOTWEB_DB_TYPE=pdo_mysql \ + -e SPOTWEB_DB_HOST= \ + -e SPOTWEB_DB_NAME=spotweb \ + -e SPOTWEB_DB_USER=spotweb \ + -e SPOTWEB_DB_PASS=spotweb \ + jgeusebroek/spotweb \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..859ffb7 --- /dev/null +++ b/build.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker build --rm -t jgeusebroek/spotweb . diff --git a/buildNoCache.sh b/buildNoCache.sh new file mode 100755 index 0000000..331e6b5 --- /dev/null +++ b/buildNoCache.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +docker build --rm --pull --no-cache -t jgeusebroek/spotweb . \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..19e8eb8 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,49 @@ +#!/bin/bash +set -x + +SPOTWEB_CRON=${SPOTWEB_CRON:-'*/15 * * * *'} + +if [ ! -f /config/ownsettings.php ] && [ -f /var/www/spotweb/ownsettings.php ]; then + cp /var/www/spotweb/ownsettings.php /config/ownsettings.php + +elif [ ! -f /config/ownsettings.php ] && [ ! -f /var/www/spotweb/ownsettings.php ]; then + touch /config/ownsettings.php +fi + +chown www-data:www-data /config/ownsettings.php +rm -f /var/www/spotweb/ownsettings.php +ln -s /config/ownsettings.php /var/www/spotweb/ownsettings.php + +if [[ -n "$SPOTWEB_DB_TYPE" && -n "$SPOTWEB_DB_HOST" && -n "$SPOTWEB_DB_NAME" && -n "$SPOTWEB_DB_USER" && -n "$SPOTWEB_DB_PASS" ]]; then + echo "Creating database configuration" + echo " /config/dbsettings.inc.php + echo "\$dbsettings['engine'] = '$SPOTWEB_DB_TYPE';" >> /config/dbsettings.inc.php + echo "\$dbsettings['host'] = '$SPOTWEB_DB_HOST';" >> /config/dbsettings.inc.php + echo "\$dbsettings['dbname'] = '$SPOTWEB_DB_NAME';" >> /config/dbsettings.inc.php + echo "\$dbsettings['user'] = '$SPOTWEB_DB_USER';" >> /config/dbsettings.inc.php + echo "\$dbsettings['pass'] = '$SPOTWEB_DB_PASS';" >> /config/dbsettings.inc.php +fi + +if [ -f /config/dbsettings.inc.php ]; then + chown www-data:www-data /config/dbsettings.inc.php + rm /var/www/spotweb/dbsettings.inc.php + ln -s /config/dbsettings.inc.php /var/www/spotweb/dbsettings.inc.php + + # Run database update + /usr/bin/php /var/www/spotweb/upgrade-db.php +else + echo "WARNING: You have no database configuration file, either create /config/dbsettings.inc.php or restart this container with the correct environment variables to auto generate the config." +fi + +echo "Updating PHP time zone" +TIMEZONE=${TIMEZONE:-"Europe/Amsterdam"} +sed -i "s#^;date.timezone =.*#date.timezone = ${TIMEZONE}#g" /etc/php5/*/php.ini + +echo "Enabling PHP mod rewrite" +/usr/sbin/a2enmod rewrite + +echo "Updating hourly cron" +(crontab -l ; echo "${SPOTWEB_CRON} /usr/bin/php /var/www/spotweb/retrieve.php | tee /var/log/spotweb-retrieve.log") | crontab - + +/etc/init.d/apache2 restart +tail -F /var/log/apache2/* \ No newline at end of file diff --git a/files/000-default.conf b/files/000-default.conf new file mode 100644 index 0000000..43ccc69 --- /dev/null +++ b/files/000-default.conf @@ -0,0 +1,15 @@ + + ServerAdmin _ + + DocumentRoot /var/www/spotweb + + RewriteEngine on + RewriteCond %{REQUEST_URI} !api/ + RewriteRule ^api/?$ index.php?page=newznabapi [QSA,L] + Options Indexes FollowSymLinks MultiViews + AllowOverride All + Order deny,allow + Allow from all + + + \ No newline at end of file