aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis Eriksen <dennis@terje.dnns.no>2019-02-09 14:48:22 +0100
committerDennis Eriksen <dennis@terje.dnns.no>2019-02-09 14:48:22 +0100
commit010e82fe94a2d2b41f518a4ac3325ffa0dc2e5b5 (patch)
treeaeb6d14bc238d172e98a6be19a9b6528e4c35042
parentInitial commit (diff)
downloaddavical-docker-010e82fe94a2d2b41f518a4ac3325ffa0dc2e5b5.tar.gz
finishing work. davical now works with my setup
-rw-r--r--Dockerfile2
-rw-r--r--env.sample13
-rw-r--r--files/etc/apache2/conf.d/davical.conf26
-rwxr-xr-xfiles/usr/local/bin/entrypoint.sh26
-rw-r--r--files/var/www/app/config.php13
-rw-r--r--files/var/www/app/config/config.php13
6 files changed, 68 insertions, 25 deletions
diff --git a/Dockerfile b/Dockerfile
index 9d49790..335f7d8 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,7 +10,9 @@ RUN apk update && apk add \
php7-apache2 \
php7-cgi \
php7-curl \
+ php7-iconv \
php7-imap \
+ php7-pdo_pgsql \
php7-pgsql \
php7-xml \
xz && \
diff --git a/env.sample b/env.sample
index 868c248..d79bdc2 100644
--- a/env.sample
+++ b/env.sample
@@ -1,2 +1,13 @@
-DATABASE_URL=''
+DATABASE_HOST=''
+DATABASE_PORT=''
+DATABASE_USER='davical_app'
+DATABASE_NAME='davical'
+DATABASE_PASSWORD=''
+ADMIN_MAIL=''
+SYSTEM_NAME='DAViCal system'
+
+APACHE_SERVER_NAME=''
+
+# Users for htpasswd. Separated by '\n'
+APACHE_USERS=''
diff --git a/files/etc/apache2/conf.d/davical.conf b/files/etc/apache2/conf.d/davical.conf
new file mode 100644
index 0000000..482eff6
--- /dev/null
+++ b/files/etc/apache2/conf.d/davical.conf
@@ -0,0 +1,26 @@
+<VirtualHost *:80>
+
+ ServerName #APACHE_SERVER_NAME
+ UseCanonicalName on
+
+ DocumentRoot /var/www/app/htdocs
+ DirectoryIndex index.php index.html
+
+ # To cirkumvent phps $_SERVER['HTTPS']-check
+ SetEnv HTTPS "on"
+
+ AcceptPathInfo On
+
+ <Directory "/var/www/app/htdocs">
+ AuthType Basic
+ AuthName "private area"
+ AuthUserFile /etc/apache2/davical.htpasswd
+ Require valid-user
+ </Directory>
+
+ <Directory "/var/www/app/htdocs/images/">
+ AllowOverride None
+ Order allow,deny
+ Allow from all
+ </Directory>
+</VirtualHost>
diff --git a/files/usr/local/bin/entrypoint.sh b/files/usr/local/bin/entrypoint.sh
index d1a1cc2..337e62a 100755
--- a/files/usr/local/bin/entrypoint.sh
+++ b/files/usr/local/bin/entrypoint.sh
@@ -1,23 +1,27 @@
#!/bin/sh
-# Apache server name change
-if [ ! -z "$APACHE_SERVER_NAME" ]
- then
- sed -i "s/#ServerName www.example.com:80/ServerName $APACHE_SERVER_NAME/" /etc/apache2/httpd.conf
- echo "Changed server name to '$APACHE_SERVER_NAME'..."
- else
- echo "NOTICE: Change 'ServerName' globally and hide server message by setting environment variable >> 'APACHE_SERVER_NAME=your.server.name' in docker command or docker-compose file"
-fi
-
# Change apache config
-sed -i 's/ServerAdmin\ you@example.com/ServerAdmin\ you@example.com/' /etc/apache2/httpd.conf
+#sed -i "s/#ServerName www.example.com:80/ServerName $APACHE_SERVER_NAME/" /etc/apache2/httpd.conf
+sed -i "s/ServerAdmin\ you@example.com/ServerAdmin\ $ADMIN_MAIL/" /etc/apache2/httpd.conf
sed -i 's/ServerSignature On/ServerSignature Off/' /etc/apache2/httpd.conf
sed -i 's#/var/www/localhost/htdocs#/var/www/app/htdocs#g' /etc/apache2/httpd.conf
+sed -i "s/#APACHE_SERVER_NAME/$APACHE_SERVER_NAME/" /etc/apache2/conf.d/davical.conf
+
+echo -e "$APACHE_USERS" > /etc/apache2/davical.htpasswd
# Modify php.ini settings
sed -i 's/memory_limit = .*/memory_limit = 256M/' /etc/php7/php.ini
-sed -i "s/^;date.timezone =$/date.timezone = \"Europe\/Stockholm\"/" /etc/php7/php.ini
+sed -i "s/^;date.timezone =$/date.timezone = \"Europe\/Oslo\"/" /etc/php7/php.ini
+# Modify davicals config.php
+sed -i "s/#APACHE_SERVER_NAME/$APACHE_SERVER_NAME/" /var/www/app/config/config.php
+sed -i "s/#ADMIN_MAIL/$ADMIN_MAIL/" /var/www/app/config/config.php
+sed -i "s/#SYSTEM_NAME/$SYSTEM_NAME/" /var/www/app/config/config.php
+sed -i "s/#DATABASE_NAME/$DATABASE_NAME/" /var/www/app/config/config.php
+sed -i "s/#DATABASE_USER/$DATABASE_USER/" /var/www/app/config/config.php
+sed -i "s/#DATABASE_PORT/$DATABASE_PORT/" /var/www/app/config/config.php
+sed -i "s/#DATABASE_HOST/$DATABASE_HOST/" /var/www/app/config/config.php
+sed -i "s/#DATABASE_PASSWORD/$DATABASE_PASSWORD/" /var/www/app/config/config.php
# display logs
tail -F /var/log/apache2/*log &
diff --git a/files/var/www/app/config.php b/files/var/www/app/config.php
deleted file mode 100644
index f25f096..0000000
--- a/files/var/www/app/config.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
- $c->domain_name = "davical.eriksen.im";
- $c->sysabbr = 'DAViCal';
- $c->admin_email = 'dennis@eriksen.im';
- $c->system_name = "Eriksens DAViCal Server";
- $c->pg_connect[] = 'dbname=davical port=5432 user=davical_app';
-
-/*
- * Use Apache-supplied headers and believe them
- */
-
- $c->authenticate_hook['server_auth_type'] = 'Basic';
- include_once('AuthPlugins.php');
diff --git a/files/var/www/app/config/config.php b/files/var/www/app/config/config.php
new file mode 100644
index 0000000..f34328e
--- /dev/null
+++ b/files/var/www/app/config/config.php
@@ -0,0 +1,13 @@
+<?php
+ $c->domain_name = "#APACHE_SERVER_NAME";
+ $c->sysabbr = 'DAViCal';
+ $c->admin_email = "#ADMIN_MAIL";
+ $c->system_name = "#SYSTEM_NAME";
+ $c->pg_connect[] = "dbname=#DATABASE_NAME port=#DATABASE_PORT user=#DATABASE_USER host=#DATABASE_HOST password=#DATABASE_PASSWORD";
+
+/*
+ * Use Apache-supplied headers and believe them
+ */
+
+ $c->authenticate_hook['server_auth_type'] = 'Basic';
+ include_once('AuthPlugins.php');