Alpinize + Dockerize SeedDMS

This commit is contained in:
Disassembler 2018-01-08 15:06:11 +01:00
parent 70243a7ddc
commit bb7171f3e1
18 changed files with 184 additions and 77 deletions

View File

@ -1,53 +1,41 @@
#!/bin/bash #!/bin/sh
SOURCE_DIR=$(realpath $(dirname "${0}"))/seeddms SOURCE_DIR=$(realpath $(dirname "${0}"))/seeddms
# Install dependencies for SeedDMS # Build Docker container
apt-get -y --no-install-recommends install ghostscript id3 imagemagick libreoffice-calc libreoffice-impress libreoffice-writer php7.0-gd php7.0-fpm php7.0-mbstring php7.0-pgsql php7.0-xml php-pear poppler-utils unoconv docker build -t seeddms ${SOURCE_DIR}
# Install SeedDMS
wget https://sourceforge.net/projects/seeddms/files/seeddms-5.1.3/seeddms-quickstart-5.1.3.tar.gz/download -O /srv/seeddms.tgz
tar xzf /srv/seeddms.tgz -C /srv
mv /srv/seeddms51x /srv/seeddms
rm -f /srv/seeddms.tgz
# Patch Previewers
patch -d /srv/seeddms -p0 <${SOURCE_DIR}/seeddms-previewers.patch
# Populate database # Populate database
export SEEDDMS_PWD=$(head -c 18 /dev/urandom | base64) export SEEDDMS_PWD=$(head -c 18 /dev/urandom | base64)
envsubst <${SOURCE_DIR}/tmp/seeddms-createdb.sql >/tmp/seeddms-createdb.sql envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql
sudo -u postgres psql -f /tmp/seeddms-createdb.sql docker run --rm seeddms cat /srv/seeddms/create_tables-postgres.sql | docker exec -i -e PGPASSWORD=${SEEDDMS_PWD} postgres psql seeddms seeddms
rm -f /tmp/seeddms-createdb.sql
export PGPASSWORD=${SEEDDMS_PWD} # Copy existing files into persistent storage
psql -f /srv/seeddms/www/install/create_tables-postgres.sql seeddms seeddms mkdir -p /srv/seeddms/conf
mkdir /srv/seeddms/data
docker run --rm -v /srv/seeddms/conf:/mnt/conf seeddms cp -rp /srv/seeddms/www/conf/. /mnt/conf
docker run --rm -v /srv/seeddms/data:/mnt/conf seeddms cp -rp /srv/seeddms/data/. /mnt/conf
chown -R 8010:8010 /srv/seeddms/data
# Configure SeedDMS # Configure SeedDMS
envsubst <${SOURCE_DIR}/srv/seeddms/www/conf/settings.xml >/srv/seeddms/www/conf/settings.xml envsubst <${SOURCE_DIR}/srv/seeddms/conf/settings.xml >/srv/seeddms/conf/settings.xml
rm -rf /srv/seeddms/www/install/
export SEEDDMS_ADMIN_USER=admin export SEEDDMS_ADMIN_USER=admin
export SEEDDMS_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) export SEEDDMS_ADMIN_PWD=$(head -c 12 /dev/urandom | base64)
export SEEDDMS_ADMIN_EMAIL=admin@example.com export SEEDDMS_ADMIN_EMAIL=admin@example.com
envsubst <${SOURCE_DIR}/tmp/seeddms-adminpwd.sql >/tmp/seeddms-adminpwd.sql envsubst <${SOURCE_DIR}/adminpwd.sql | docker exec -i postgres psql seeddms
psql -f /tmp/seeddms-adminpwd.sql seeddms seeddms
unset PGPASSWORD
rm -f /tmp/seeddms-adminpwd.sql
# Create OS user # Create SeedDMS service
adduser --system --group --home /srv/seeddms --shell /bin/false seeddms cp ${SOURCE_DIR}/etc/init.d/seeddms /etc/init.d/seeddms
chown -R seeddms:www-data /srv/seeddms/ rc-update add seeddms boot
service seeddms start
# Create PHP and nginx app definition # Create nginx app definition
cp ${SOURCE_DIR}/etc/php/7.0/fpm/pool.d/seeddms.conf /etc/php/7.0/fpm/pool.d/seeddms.conf cp ${SOURCE_DIR}/etc/nginx/apps/seeddms /etc/nginx/apps/seeddms
cp ${SOURCE_DIR}/etc/nginx/apps-available/seeddms /etc/nginx/apps-available/seeddms cp ${SOURCE_DIR}/etc/nginx/conf.d/seeddms.conf /etc/nginx/conf.d/seeddms.conf
ln -s /etc/nginx/apps-available/seeddms /etc/nginx/apps-enabled/seeddms service nginx reload
# Restart services
systemctl restart php7.0-fpm
systemctl restart nginx
# Install cron job # Install cron job
cp ${SOURCE_DIR}/etc/cron.d/seeddms /etc/cron.d/seeddms cp ${SOURCE_DIR}/etc/periodic/hourly/seeddms /etc/periodic/hourly/seeddms
# Add portal application definition # Add portal application definition
portal-app-manager seeddms "/seeddms/" "${SEEDDMS_ADMIN_USER}" "${SEEDDMS_ADMIN_PWD}" portal-app-manager seeddms "https://{host}:8410/" "${SEEDDMS_ADMIN_USER}" "${SEEDDMS_ADMIN_PWD}"

42
seeddms/Dockerfile Normal file
View File

@ -0,0 +1,42 @@
FROM alpine:3.7
MAINTAINER Disassembler <disassembler@dasm.cz>
RUN \
# Install PHP runtime
apk --no-cache add nginx php7-fpm s6
RUN \
# Install runtime dependencies
apk --no-cache add ghostscript imagemagick libreoffice-calc libreoffice-impress libreoffice-writer php7-gd php7-iconv php7-json php7-mbstring php7-pear php7-pdo_pgsql php7-simplexml php7-xml poppler-utils \
# Install unoconv
&& wget https://raw.githubusercontent.com/dagwieers/unoconv/master/unoconv -O /usr/local/bin/unoconv \
&& chmod +x /usr/local/bin/unoconv \
&& ln -s /usr/bin/python3 /usr/bin/python
RUN \
# Install SeedDMS
wget https://sourceforge.net/projects/seeddms/files/seeddms-5.1.5/seeddms-quickstart-5.1.5.tar.gz/download -O /srv/seeddms.tgz \
&& tar xzf /srv/seeddms.tgz -C /srv \
&& mv /srv/seeddms51x /srv/seeddms \
&& rm -f /srv/seeddms.tgz \
&& chown -R root:root /srv/seeddms \
# Create OS user
&& addgroup -S -g 8010 seeddms \
&& adduser -S -u 8010 -h /srv/seeddms -s /bin/false -g seeddms -G seeddms seeddms \
# Cleanup
&& cp /srv/seeddms/www/install/create_tables-postgres.sql /srv/seeddms/create_tables-postgres.sql \
&& rm -rf /srv/seeddms/www/install
COPY docker/ /
RUN \
# Patch Previewers
cd /srv/seeddms \
&& patch -p0 </srv/seeddms/previewers.patch
# TODO: id3 ?
VOLUME ["/srv/seeddms/www/config", "/srv/seeddms/data"]
EXPOSE 8010
CMD ["s6-svscan", "/etc/services.d"]

View File

@ -0,0 +1,39 @@
user nginx;
pid /run/nginx.pid;
worker_processes 1;
error_log /dev/stderr warn;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log off;
server_tokens off;
client_max_body_size 100m;
keepalive_timeout 65;
sendfile on;
tcp_nodelay on;
server {
listen 8010;
server_name localhost;
root /srv/seeddms/www;
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/seeddms.sock;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_index index.php;
include fastcgi_params;
}
}
}

View File

@ -0,0 +1,16 @@
[global]
error_log = /proc/self/fd/2
daemonize = no
[seeddms]
catch_workers_output = yes
user = seeddms
group = seeddms
listen.owner = nginx
listen.group = nginx
listen = /var/run/seeddms.sock
pm = ondemand
pm.max_children = 8
php_admin_value[upload_max_filesize] = 100M
php_admin_value[include_path] = '/srv/seeddms/www/:/srv/seeddms/pear:/usr/share/php7:.:'
env[LANG]=en_US.UTF-8

View File

@ -0,0 +1,3 @@
#!/bin/sh
/bin/true

View File

@ -0,0 +1,3 @@
#!/bin/execlineb -P
nginx -g "daemon off;"

View File

@ -0,0 +1,3 @@
#!/bin/execlineb -P
php-fpm7 -F

View File

@ -1,7 +1,7 @@
diff -ruN orig/SeedDMS/Preview/PdfPreviewer.php pear/SeedDMS/Preview/PdfPreviewer.php diff -ruN orig/SeedDMS/Preview/PdfPreviewer.php pear/SeedDMS/Preview/PdfPreviewer.php
--- orig/SeedDMS/Preview/PdfPreviewer.php 2017-05-03 14:14:18.000000000 +0200 --- orig/SeedDMS/Preview/PdfPreviewer.php 2017-12-15 08:23:09.000000000 +0100
+++ pear/SeedDMS/Preview/PdfPreviewer.php 2017-10-07 19:01:01.169624330 +0200 +++ pear/SeedDMS/Preview/PdfPreviewer.php 2018-01-04 09:55:06.117665300 +0100
@@ -27,10 +27,18 @@ @@ -27,12 +27,17 @@
function __construct($previewDir, $timeout=5) { /* {{{ */ function __construct($previewDir, $timeout=5) { /* {{{ */
parent::__construct($previewDir, $timeout); parent::__construct($previewDir, $timeout);
$this->converters = array( $this->converters = array(
@ -9,6 +9,8 @@ diff -ruN orig/SeedDMS/Preview/PdfPreviewer.php pear/SeedDMS/Preview/PdfPreviewe
- 'application/vnd.oasis.opendocument.text' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'", - 'application/vnd.oasis.opendocument.text' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
'text/rtf' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'", 'text/rtf' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
'application/msword' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'", 'application/msword' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
- 'application/vnd.ms-excel' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
+ 'application/vnd.oasis.opendocument.text' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'", + 'application/vnd.oasis.opendocument.text' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'", + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
+ 'application/vnd.ms-excel' => "unoconv -d spreadsheet -f pdf --stdout -v '%f' > '%o'", + 'application/vnd.ms-excel' => "unoconv -d spreadsheet -f pdf --stdout -v '%f' > '%o'",
@ -18,19 +20,16 @@ diff -ruN orig/SeedDMS/Preview/PdfPreviewer.php pear/SeedDMS/Preview/PdfPreviewe
+ 'application/vnd.oasis.opendocument.presentation' => "unoconv -d presentation -f pdf --stdout -v '%f' > '%o'", + 'application/vnd.oasis.opendocument.presentation' => "unoconv -d presentation -f pdf --stdout -v '%f' > '%o'",
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => "unoconv -d presentation -f pdf --stdout -v '%f' > '%o'", + 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => "unoconv -d presentation -f pdf --stdout -v '%f' > '%o'",
+ 'text/html' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'", + 'text/html' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
+ 'text/plain' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'", 'text/plain' => "unoconv -d document -f pdf --stdout -v '%f' > '%o'",
); 'application/postscript' => "ps2pdf '%f' - > '%o'",
} /* }}} */ 'image/jpeg' => "convert '%f' pdf:- > '%o'",
diff -ruN orig/SeedDMS/Preview/Previewer.php pear/SeedDMS/Preview/Previewer.php diff -ruN orig/SeedDMS/Preview/Previewer.php pear/SeedDMS/Preview/Previewer.php
--- orig/SeedDMS/Preview/Previewer.php 2017-05-03 14:14:18.000000000 +0200 --- orig/SeedDMS/Preview/Previewer.php 2017-12-15 08:23:09.000000000 +0100
+++ pear/SeedDMS/Preview/Previewer.php 2017-10-07 19:02:22.781623907 +0200 +++ pear/SeedDMS/Preview/Previewer.php 2018-01-04 09:56:12.359902000 +0100
@@ -40,7 +40,19 @@ @@ -41,6 +41,18 @@
'text/plain' => "convert -resize %wx '%f' '%o'",
'application/pdf' => "convert -density 100 -resize %wx '%f[0]' '%o'", 'application/pdf' => "convert -density 100 -resize %wx '%f[0]' '%o'",
'application/postscript' => "convert -density 100 -resize %wx '%f[0]' '%o'", 'application/postscript' => "convert -density 100 -resize %wx '%f[0]' '%o'",
- 'application/x-compressed-tar' => "tar tzvf '%f' | convert -density 100 -resize %wx text:-[0] '%o", 'application/x-compressed-tar' => "tar tzvf '%f' | convert -density 100 -resize %wx text:-[0] '%o'",
+ 'application/x-compressed-tar' => "tar tzvf '%f' | convert -density 100 -resize %wx text:-[0] '%o'",
+ 'text/rtf' => "unoconv -d document -e PageRange=1-1 -f pdf --stdout '%f' | convert -resize %wx pdf:- '%o'", + 'text/rtf' => "unoconv -d document -e PageRange=1-1 -f pdf --stdout '%f' | convert -resize %wx pdf:- '%o'",
+ 'application/msword' => "unoconv -d document -e PageRange=1-1 -f pdf --stdout '%f' | convert -resize %wx pdf:- '%o'", + 'application/msword' => "unoconv -d document -e PageRange=1-1 -f pdf --stdout '%f' | convert -resize %wx pdf:- '%o'",
+ 'application/vnd.oasis.opendocument.text' => "unoconv -d document -e PageRange=1-1 -f pdf --stdout '%f' | convert -resize %wx pdf:- '%o'", + 'application/vnd.oasis.opendocument.text' => "unoconv -d document -e PageRange=1-1 -f pdf --stdout '%f' | convert -resize %wx pdf:- '%o'",

View File

@ -1 +0,0 @@
5,35 * * * * seeddms cd /srv/seeddms/www/utils/ && /usr/bin/php indexer.php --config ../conf/settings.xml >/dev/null

17
seeddms/etc/init.d/seeddms Executable file
View File

@ -0,0 +1,17 @@
#!/sbin/openrc-run
description="SeedDMS docker container"
depend() {
need docker net
use dns logger netmount
after postgres
}
start() {
/usr/bin/docker run -d --rm --name seeddms --link=postgres -p 127.0.0.1:9010:8010 -v /srv/seeddms/data:/srv/seeddms/data -v /srv/seeddms/conf:/srv/seeddms/www/conf seeddms
}
stop() {
/usr/bin/docker stop seeddms
}

View File

@ -1,10 +0,0 @@
location /seeddms {
alias /srv/seeddms/www;
index index.php;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php/seeddms.sock;
}
}

View File

@ -0,0 +1,9 @@
access_log /var/log/nginx/seeddms.access.log;
error_log /var/log/nginx/seeddms.error.log;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:9010;
}

View File

@ -0,0 +1,11 @@
server {
listen 8010;
listen [::]:8010;
include apps/seeddms;
}
server {
listen 8410 ssl http2;
listen [::]:8410 ssl http2;
include apps/seeddms;
}

View File

@ -0,0 +1,3 @@
#!/bin/sh
docker exec seeddms "cd /srv/seeddms/www/utils/ && /usr/bin/php indexer.php --config ../conf/settings.xml" >/dev/null

View File

@ -1,15 +0,0 @@
[seeddms]
user = seeddms
group = seeddms
listen = /run/php/seeddms.sock
listen.owner = www-data
listen.group = www-data
pm = ondemand
pm.max_children = 8
php_admin_value[open_basedir] = /srv/seeddms:/tmp:/usr/share/php
php_admin_value[upload_max_filesize] = 100M
env[LANG]=en_US.UTF-8

View File

@ -6,14 +6,14 @@
<calendar enableCalendar="true" calendarDefaultView="w" firstDayOfWeek="1"/> <calendar enableCalendar="true" calendarDefaultView="w" firstDayOfWeek="1"/>
</site> </site>
<system> <system>
<server rootDir="/srv/seeddms/www/" httpRoot="/seeddms/" contentDir="/srv/seeddms/data/" stagingDir="/srv/seeddms/data/staging/" luceneDir="/srv/seeddms/data/lucene/" logFileEnable="true" logFileRotation="d" enableLargeFileUpload="true" partitionSize="2000000" dropFolderDir="" cacheDir="/srv/seeddms/data/cache/" maxUploadSize=""/> <server rootDir="/srv/seeddms/www/" httpRoot="/" contentDir="/srv/seeddms/data/" stagingDir="/srv/seeddms/data/staging/" luceneDir="/srv/seeddms/data/lucene/" logFileEnable="true" logFileRotation="d" enableLargeFileUpload="true" partitionSize="2000000" dropFolderDir="" cacheDir="/srv/seeddms/data/cache/" maxUploadSize=""/>
<authentication enableGuestLogin="false" enablePasswordForgotten="true" restricted="true" enableUserImage="false" disableSelfEdit="false" passwordStrength="0" passwordExpiration="0" passwordHistory="0" passwordStrengthAlgorithm="advanced" loginFailure="0" encryptionKey="" enableGuestAutoLogin="false" autoLoginUser="0" quota="0" undelUserIds="" cookieLifetime="0" defaultAccessDocs="0"> <authentication enableGuestLogin="false" enablePasswordForgotten="true" restricted="true" enableUserImage="false" disableSelfEdit="false" passwordStrength="0" passwordExpiration="0" passwordHistory="0" passwordStrengthAlgorithm="advanced" loginFailure="0" encryptionKey="" enableGuestAutoLogin="false" autoLoginUser="0" quota="0" undelUserIds="" cookieLifetime="0" defaultAccessDocs="0">
<connectors> <connectors>
<connector enable="false" type="ldap" host="ldaps://ldap.host.com" port="389" baseDN="" bindDN="" bindPw="" filter=""/> <connector enable="false" type="ldap" host="ldaps://ldap.host.com" port="389" baseDN="" bindDN="" bindPw="" filter=""/>
<connector enable="false" type="AD" host="ldap.example.com" port="389" baseDN="" accountDomainName="example.com" bindDN="" bindPw=""/> <connector enable="false" type="AD" host="ldap.example.com" port="389" baseDN="" accountDomainName="example.com" bindDN="" bindPw=""/>
</connectors> </connectors>
</authentication> </authentication>
<database dbDriver="pgsql" dbHostname="localhost" dbDatabase="seeddms" dbUser="seeddms" dbPass="${SEEDDMS_PWD}" doNotCheckVersion="false"/> <database dbDriver="pgsql" dbHostname="postgres" dbDatabase="seeddms" dbUser="seeddms" dbPass="${SEEDDMS_PWD}" doNotCheckVersion="false"/>
<smtp smtpServer="localhost" smtpPort="25" smtpSendFrom="seeddms@localhost" smtpUser="" smtpPassword=""/> <smtp smtpServer="localhost" smtpPort="25" smtpSendFrom="seeddms@localhost" smtpUser="" smtpPassword=""/>
</system> </system>
<advanced> <advanced>