Initial Commit

This commit is contained in:
Jeroen Geusebroek 2016-01-17 21:53:50 +01:00
commit eb9f261070
8 changed files with 140 additions and 0 deletions

11
.dockerignore Normal file
View File

@ -0,0 +1,11 @@
# Git files
.git
.gitignore
#build files
build.sh
buildNoCache.sh
# Information files
LICENSE
README.md

13
.gitignore vendored Normal file
View File

@ -0,0 +1,13 @@
# Created by .gitignore support plugin (hsz.mobi)
.idea
*.iml
# OSX
.DS_Store
.AppleDouble
.LSOverride
# Linux
*~
.directory
.Trash-*

37
Dockerfile Normal file
View File

@ -0,0 +1,37 @@
FROM ubuntu:15.10
MAINTAINER Jeroen Geusebroek <me@jeroengeusebroek.nl>
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"]

11
README.md Normal file
View File

@ -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=<hostname> \
-e SPOTWEB_DB_NAME=spotweb \
-e SPOTWEB_DB_USER=spotweb \
-e SPOTWEB_DB_PASS=spotweb \
jgeusebroek/spotweb

2
build.sh Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
docker build --rm -t jgeusebroek/spotweb .

2
buildNoCache.sh Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
docker build --rm --pull --no-cache -t jgeusebroek/spotweb .

49
entrypoint.sh Normal file
View File

@ -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 "<?php" > /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/*

15
files/000-default.conf Normal file
View File

@ -0,0 +1,15 @@
<VirtualHost *:80>
ServerAdmin _
DocumentRoot /var/www/spotweb
<Directory /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
</Directory>
</VirtualHost>