mirror of
https://bitbucket.org/jsuto/piler.git
synced 2025-01-12 22:20:12 +01:00
Added docker support
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
7015e76a11
commit
65cc7ebc76
@ -4,9 +4,6 @@ server {
|
|||||||
|
|
||||||
root /var/piler/www;
|
root /var/piler/www;
|
||||||
|
|
||||||
access_log /var/log/nginx/access.log;
|
|
||||||
error_log /var/log/nginx/error.log;
|
|
||||||
|
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_types text/plain application/xml text/css;
|
gzip_types text/plain application/xml text/css;
|
||||||
gzip_vary on;
|
gzip_vary on;
|
||||||
@ -31,8 +28,7 @@ server {
|
|||||||
return 404;
|
return 404;
|
||||||
}
|
}
|
||||||
|
|
||||||
#fastcgi_pass unix:/var/run/php5-fpm.sock;
|
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
|
||||||
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
|
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
}
|
}
|
||||||
|
47
docker/Dockerfile
Normal file
47
docker/Dockerfile
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
FROM ubuntu:18.04
|
||||||
|
|
||||||
|
ARG PACKAGE
|
||||||
|
|
||||||
|
LABEL description="piler container" \
|
||||||
|
maintainer="Janos SUTO, sj@acts.hu"
|
||||||
|
package="${PACKAGE}"
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND="noninteractive" \
|
||||||
|
DISTRO="bionic" \
|
||||||
|
DOWNLOAD_URL="https://download.mailpiler.com" \
|
||||||
|
PILER_USER="piler" \
|
||||||
|
MYSQL_HOSTNAME="localhost" \
|
||||||
|
MYSQL_DATABASE="piler" \
|
||||||
|
MYSQL_PILER_PASSWORD="piler123" \
|
||||||
|
MYSQL_ROOT_PASSWORD="abcde123" \
|
||||||
|
SPHINX_BIN_TARGZ="sphinx-3.1.1-bin.tar.gz"
|
||||||
|
|
||||||
|
ADD "https://bitbucket.org/jsuto/piler/downloads/${PACKAGE}" "/${PACKAGE}"
|
||||||
|
ADD files/start.sh /start.sh
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get -y --no-install-recommends install \
|
||||||
|
wget rsyslog openssl sysstat php7.2-cli php7.2-cgi php7.2-mysql php7.2-fpm php7.2-zip php7.2-ldap \
|
||||||
|
php7.2-gd php7.2-curl php7.2-xml catdoc unrtf poppler-utils nginx tnef sudo libodbc1 libpq5 libzip4 \
|
||||||
|
libtre5 libwrap0 cron libmariadb3 libmysqlclient-dev python python-mysqldb mariadb-server && \
|
||||||
|
service mysql start && mysqladmin -u root password ${MYSQL_ROOT_PASSWORD} && \
|
||||||
|
wget --no-check-certificate -q -O ${SPHINX_BIN_TARGZ} ${DOWNLOAD_URL}/generic-local/${SPHINX_BIN_TARGZ} && \
|
||||||
|
tar zxvf ${SPHINX_BIN_TARGZ} && \
|
||||||
|
rm -f ${SPHINX_BIN_TARGZ} && \
|
||||||
|
sed -i 's/mail.[iwe].*//' /etc/rsyslog.conf && \
|
||||||
|
sed -i '/session required pam_loginuid.so/c\#session required pam_loginuid.so' /etc/pam.d/cron && \
|
||||||
|
mkdir /etc/piler && \
|
||||||
|
printf "[mysql]\nuser = piler\npassword = ${MYSQL_PILER_PASSWORD}\n" > /etc/piler/.my.cnf && \
|
||||||
|
printf "[mysql]\nuser = root\npassword = ${MYSQL_ROOT_PASSWORD}\n" > /root/.my.cnf && \
|
||||||
|
echo "alias mysql='mysql --defaults-file=/etc/piler/.my.cnf'" > /root/.bashrc && \
|
||||||
|
echo "alias t='tail -f /var/log/syslog'" >> /root/.bashrc && \
|
||||||
|
dpkg -i $PACKAGE && \
|
||||||
|
crontab -u $PILER_USER /usr/share/piler/piler.cron && \
|
||||||
|
touch /var/log/mail.log && \
|
||||||
|
rm -f $PACKAGE /etc/nginx/sites-enabled/default && \
|
||||||
|
sed -i 's/#ngram/ngram/g' /etc/piler/sphinx.conf.dist && \
|
||||||
|
sed -i 's/220/311/g' /etc/piler/sphinx.conf.dist
|
||||||
|
|
||||||
|
EXPOSE 25 80 443
|
||||||
|
VOLUME ["/var/piler"]
|
||||||
|
CMD ["/start.sh"]
|
94
docker/start.sh
Executable file
94
docker/start.sh
Executable file
@ -0,0 +1,94 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
|
DATAROOTDIR="/usr/share"
|
||||||
|
SYSCONFDIR="/etc"
|
||||||
|
SPHINXCFG="/etc/piler/sphinx.conf"
|
||||||
|
PILER_HOST=${PILER_HOST:-archive.yourdomain.com}
|
||||||
|
PILER_CONF="/etc/piler/piler.conf"
|
||||||
|
CONFIG_SITE_PHP="/etc/piler/config-site.php"
|
||||||
|
CONFIG_PHP="/var/piler/www/config.php"
|
||||||
|
|
||||||
|
create_mysql_db() {
|
||||||
|
echo "Creating mysql database"
|
||||||
|
|
||||||
|
sed -e "s%MYSQL_HOSTNAME%${MYSQL_HOSTNAME}%g" \
|
||||||
|
-e "s%MYSQL_DATABASE%${MYSQL_DATABASE}%g" \
|
||||||
|
-e "s%MYSQL_USERNAME%${PILER_USER}%g" \
|
||||||
|
-e "s%MYSQL_PASSWORD%${MYSQL_PILER_PASSWORD}%g" \
|
||||||
|
"${DATAROOTDIR}/piler/db-mysql-root.sql.in" | \
|
||||||
|
mysql -h "$MYSQL_HOSTNAME" -u root --password="$MYSQL_ROOT_PASSWORD"
|
||||||
|
|
||||||
|
mysql -h "$MYSQL_HOSTNAME" -u "$PILER_USER" --password="$MYSQL_PILER_PASSWORD" "$MYSQL_DATABASE" < "${DATAROOTDIR}/piler/db-mysql.sql"
|
||||||
|
|
||||||
|
echo "Done."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pre_seed_sphinx() {
|
||||||
|
echo "Writing sphinx configuration"
|
||||||
|
sed -e "s%MYSQL_HOSTNAME%${MYSQL_HOSTNAME}%" \
|
||||||
|
-e "s%MYSQL_DATABASE%${MYSQL_DATABASE}%" \
|
||||||
|
-e "s%MYSQL_USERNAME%${PILER_USER}%" \
|
||||||
|
-e "s%MYSQL_PASSWORD%${MYSQL_PILER_PASSWORD}%" \
|
||||||
|
-e "s%220%311%" \
|
||||||
|
-e "s%type = mysql%type = mysql\n sql_sock = /var/run/mysqld/mysqld.sock%" \
|
||||||
|
"${SYSCONFDIR}/piler/sphinx.conf.dist" > "$SPHINXCFG"
|
||||||
|
|
||||||
|
echo "Done."
|
||||||
|
|
||||||
|
echo "Initializing sphinx indices"
|
||||||
|
su "$PILER_USER" -c "indexer --all --config ${SYSCONFDIR}/piler/sphinx.conf"
|
||||||
|
echo "Done."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fix_configs() {
|
||||||
|
local piler_nginx_conf="/etc/piler/piler-nginx.conf"
|
||||||
|
|
||||||
|
if [[ ! -f "$PILER_CONF" ]]; then
|
||||||
|
cp /etc/piler/piler.conf.dist "$PILER_CONF"
|
||||||
|
chmod 640 "$PILER_CONF"
|
||||||
|
chown root:piler "$PILER_CONF"
|
||||||
|
sed -i "s%hostid=.*%hostid=${PILER_HOST%%:*}%" "$PILER_CONF"
|
||||||
|
sed -i "s%tls_enable=.*%tls_enable=1%" "$PILER_CONF"
|
||||||
|
sed -i "s%mysqlpwd=.*%mysqlpwd=${MYSQL_PILER_PASSWORD}%" "$PILER_CONF"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "$piler_nginx_conf" ]]; then
|
||||||
|
cp /etc/piler/piler-nginx.conf.dist "$piler_nginx_conf"
|
||||||
|
sed -i "s%PILER_HOST%${PILER_HOST}%" "$piler_nginx_conf"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ln -sf "$piler_nginx_conf" /etc/nginx/sites-enabled/piler
|
||||||
|
|
||||||
|
sed -i "s%HOSTNAME%${PILER_HOST}%" "$CONFIG_SITE_PHP"
|
||||||
|
sed -i "s%MYSQL_PASSWORD%${MYSQL_PILER_PASSWORD}%" "$CONFIG_SITE_PHP"
|
||||||
|
|
||||||
|
sed -i "s%^\$config\['DECRYPT_BINARY'\].*%\$config\['DECRYPT_BINARY'\] = '/usr/bin/pilerget';%" "$CONFIG_PHP"
|
||||||
|
sed -i "s%^\$config\['DECRYPT_ATTACHMENT_BINARY'\].*%\$config\['DECRYPT_ATTACHMENT_BINARY'\] = '/usr/bin/pileraget';%" "$CONFIG_PHP"
|
||||||
|
sed -i "s%^\$config\['PILER_BINARY'\].*%\$config\['PILER_BINARY'\] = '/usr/sbin/piler';%" "$CONFIG_PHP"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
service rsyslog start
|
||||||
|
service mysql start
|
||||||
|
|
||||||
|
create_mysql_db
|
||||||
|
pre_seed_sphinx
|
||||||
|
fix_configs
|
||||||
|
|
||||||
|
service cron start
|
||||||
|
service php7.2-fpm start
|
||||||
|
service nginx start
|
||||||
|
/etc/init.d/rc.searchd start
|
||||||
|
|
||||||
|
# fix for overlay, https://github.com/phusion/baseimage-docker/issues/198
|
||||||
|
touch /var/spool/cron/crontabs/piler
|
||||||
|
|
||||||
|
/etc/init.d/rc.piler start
|
||||||
|
|
||||||
|
while true; do sleep 120; done
|
@ -9,9 +9,9 @@
|
|||||||
#include "piler-config.h"
|
#include "piler-config.h"
|
||||||
#include "params.h"
|
#include "params.h"
|
||||||
|
|
||||||
#define VERSION "1.3.5"
|
#define VERSION "1.3.6"
|
||||||
|
|
||||||
#define BUILD 997
|
#define BUILD 998
|
||||||
|
|
||||||
#define HOSTID "mailarchiver"
|
#define HOSTID "mailarchiver"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user