Refactor 1.7 code into 1.8 code and move to Buster

This commit is contained in:
Erik Huelsmann 2020-04-12 20:01:07 +02:00
parent ba202372fa
commit 46637422ee
3 changed files with 122 additions and 79 deletions

View File

@ -1,26 +1,16 @@
FROM debian:stretch-slim FROM debian:buster-slim
MAINTAINER Freelock john@freelock.com MAINTAINER Freelock john@freelock.com
# Build time variables # Build time variables
ARG LSMB_VERSION="1.7.9" ARG LSMB_VERSION="1.8.0-alpha1"
ARG LSMB_DL_DIR="Releases" ARG LSMB_DL_DIR="Beta Releases"
# Install Perl, Tex, Starman, psql client, and all dependencies # Install Perl, Tex, Starman, psql client, and all dependencies
# Without libclass-c3-xs-perl, performance is terribly slow... # Without libclass-c3-xs-perl, performance is terribly slow...
# Without libclass-accessor-lite-perl, HTML::Entities won't build from CPAN
# libnet-cidr-lite-perl is a dependency for Plack::Builder::Conditionals
# which is being installed from CPAN
# libtest-requires-perl is a dependency of Module-Build-Pluggable-PPPort
# on which HTML::Escape depends
# Installing psql client directly from instructions at https://wiki.postgresql.org/wiki/Apt # Installing psql client directly from instructions at https://wiki.postgresql.org/wiki/Apt
# That mitigates issues where the PG instance is running a newer version than this container # That mitigates issues where the PG instance is running a newer version than this container
# for Buster, add:
# libhtml-escape-perl \
# libplack-middleware-builder-conditionals-perl \
# libplack-request-withencoding-perl \
#libversion-compare-perl
RUN echo -n "APT::Install-Recommends \"0\";\nAPT::Install-Suggests \"0\";\n" >> /etc/apt/apt.conf && \ RUN echo -n "APT::Install-Recommends \"0\";\nAPT::Install-Suggests \"0\";\n" >> /etc/apt/apt.conf && \
mkdir -p /usr/share/man/man1/ && \ mkdir -p /usr/share/man/man1/ && \
mkdir -p /usr/share/man/man2/ && \ mkdir -p /usr/share/man/man2/ && \
@ -29,41 +19,44 @@ RUN echo -n "APT::Install-Recommends \"0\";\nAPT::Install-Suggests \"0\";\n" >>
mkdir -p /usr/share/man/man5/ && \ mkdir -p /usr/share/man/man5/ && \
mkdir -p /usr/share/man/man6/ && \ mkdir -p /usr/share/man/man6/ && \
mkdir -p /usr/share/man/man7/ && \ mkdir -p /usr/share/man/man7/ && \
DEBIAN_FRONTEND="noninteractive" apt-get update -q && \ DEBIAN_FRONTEND="noninteractive" apt-get -y update && \
DEBIAN_FRONTEND="noninteractive" apt-get dist-upgrade -y -q && \ DEBIAN_FRONTEND="noninteractive" apt-get -y upgrade && \
DEBIAN_FRONTEND="noninteractive" apt-get -y -q install \ DEBIAN_FRONTEND="noninteractive" apt-get -y install \
wget ca-certificates gnupg \ wget ca-certificates gnupg \
libcgi-emulate-psgi-perl libconfig-inifiles-perl \ libcgi-emulate-psgi-perl libconfig-inifiles-perl \
libdbd-pg-perl libdbi-perl libdata-uuid-perl libdatetime-perl \ libcookie-baker-perl libdbd-pg-perl libdbi-perl libdata-uuid-perl \
libdatetime-format-strptime-perl \ libdatetime-perl libdatetime-format-strptime-perl \
libio-stringy-perl \ libemail-sender-perl libemail-stuffer-perl libfile-find-rule-perl \
libcpanel-json-xs-perl liblist-moreutils-perl \ libhtml-escape-perl libhttp-headers-fast-perl libio-stringy-perl \
libjson-maybexs-perl libcpanel-json-xs-perl libjson-pp-perl \
liblist-moreutils-perl \
liblocale-maketext-perl liblocale-maketext-lexicon-perl \ liblocale-maketext-perl liblocale-maketext-lexicon-perl \
liblog-log4perl-perl libmime-lite-perl libmime-types-perl \ liblog-log4perl-perl libmime-types-perl \
libmath-bigint-gmp-perl libmodule-runtime-perl libmoose-perl \ libmath-bigint-gmp-perl libmodule-runtime-perl libmoo-perl \
libmoox-types-mooselike-perl libmoose-perl \
libmoosex-nonmoose-perl libnumber-format-perl \ libmoosex-nonmoose-perl libnumber-format-perl \
libpgobject-perl libpgobject-simple-perl libpgobject-simple-role-perl \ libpgobject-perl libpgobject-simple-perl libpgobject-simple-role-perl \
libpgobject-type-bigfloat-perl libpgobject-type-datetime-perl \ libpgobject-type-bigfloat-perl libpgobject-type-datetime-perl \
libpgobject-type-bytestring-perl libpgobject-util-dbmethod-perl \ libpgobject-type-bytestring-perl libpgobject-util-dbmethod-perl \
libpgobject-util-dbadmin-perl libplack-perl \ libpgobject-util-dbadmin-perl libplack-perl \
libplack-middleware-reverseproxy-perl \ libplack-builder-conditionals-perl libplack-middleware-reverseproxy-perl \
libplack-request-withencoding-perl libscope-guard-perl \
libsession-storage-secure-perl libstring-random-perl \
libtemplate-perl libtext-csv-perl libtext-csv-xs-perl \ libtemplate-perl libtext-csv-perl libtext-csv-xs-perl \
libtext-markdown-perl libxml-simple-perl \ libtext-markdown-perl libtry-tiny-perl libversion-compare-perl \
libnamespace-autoclean-perl \ libxml-simple-perl libnamespace-autoclean-perl \
libfile-find-rule-perl \ starman starlet libhttp-parser-xs-perl \
libtemplate-plugin-latex-perl libtex-encode-perl \ libtemplate-plugin-latex-perl libtex-encode-perl \
libclass-c3-xs-perl libclass-accessor-lite-perl \ libxml-twig-perl libopenoffice-oodoc-perl \
libnet-cidr-lite-perl \ libexcel-writer-xlsx-perl libspreadsheet-writeexcel-perl \
libclass-c3-xs-perl \
texlive-latex-recommended \ texlive-latex-recommended \
texlive-xetex fonts-liberation \ texlive-xetex fonts-liberation \
starman \
libopenoffice-oodoc-perl \
ssmtp \
lsb-release && \ lsb-release && \
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \ echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
(wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -) && \ (wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -) && \
DEBIAN_FRONTEND="noninteractive" apt-get -q -y update && \ DEBIAN_FRONTEND="noninteractive" apt-get -y update && \
DEBIAN_FRONTEND="noninteractive" apt-get -q -y install postgresql-client && \ DEBIAN_FRONTEND="noninteractive" apt-get -y install postgresql-client && \
DEBIAN_FRONTEND="noninteractive" apt-get -q -y install git cpanminus make gcc libperl-dev && \ DEBIAN_FRONTEND="noninteractive" apt-get -q -y install git cpanminus make gcc libperl-dev && \
wget --quiet -O /tmp/ledgersmb-$LSMB_VERSION.tar.gz "https://download.ledgersmb.org/f/$LSMB_DL_DIR/$LSMB_VERSION/ledgersmb-$LSMB_VERSION.tar.gz" && \ wget --quiet -O /tmp/ledgersmb-$LSMB_VERSION.tar.gz "https://download.ledgersmb.org/f/$LSMB_DL_DIR/$LSMB_VERSION/ledgersmb-$LSMB_VERSION.tar.gz" && \
tar -xzf /tmp/ledgersmb-$LSMB_VERSION.tar.gz --directory /srv && \ tar -xzf /tmp/ledgersmb-$LSMB_VERSION.tar.gz --directory /srv && \
@ -76,8 +69,7 @@ RUN echo -n "APT::Install-Recommends \"0\";\nAPT::Install-Suggests \"0\";\n" >>
apt-get purge -q -y git cpanminus make gcc libperl-dev && \ apt-get purge -q -y git cpanminus make gcc libperl-dev && \
apt-get autoremove -q -y && \ apt-get autoremove -q -y && \
apt-get autoclean -q && \ apt-get autoclean -q && \
rm -rf ~/.cpanm/ && \ rm -rf ~/.cpanm/ /var/lib/apt/lists/* /usr/share/man/*
rm -rf /var/lib/apt/lists/* /usr/share/man/*
WORKDIR /srv/ledgersmb WORKDIR /srv/ledgersmb
@ -86,30 +78,27 @@ WORKDIR /srv/ledgersmb
# Configure outgoing mail to use host, other run time variable defaults # Configure outgoing mail to use host, other run time variable defaults
## sSMTP ## MAIL
ENV SSMTP_ROOT ar@example.com ENV LSMB_MAIL_SMTPHOST 172.17.0.1
ENV SSMTP_MAILHUB 172.17.0.1 #ENV LSMB_MAIL_SMTPPORT 25
ENV SSMTP_HOSTNAME 172.17.0.1 #ENV LSMB_MAIL_SMTPSENDER_HOSTNAME (container hostname)
#ENV SSMTP_USE_STARTTLS #ENV LSMB_MAIL_SMTPTLS
#ENV SSMTP_AUTH_USER #ENV LSMB_MAIL_SMTPUSER
#ENV SSMTP_AUTH_PASS #ENV LSMB_MAIL_SMTPPASS
ENV SSMTP_FROMLINE_OVERRIDE YES #ENV LSMB_MAIL_SMTPAUTHMECH
#ENV SSMTP_AUTH_METHOD
## DATABASE
ENV POSTGRES_HOST postgres ENV POSTGRES_HOST postgres
ENV POSTGRES_PORT 5432 ENV POSTGRES_PORT 5432
ENV DEFAULT_DB lsmb ENV DEFAULT_DB lsmb
COPY start.sh /usr/local/bin/start.sh COPY start.sh /usr/local/bin/start.sh
COPY update_ssmtp.sh /usr/local/bin/update_ssmtp.sh
RUN chown www-data /etc/ssmtp /etc/ssmtp/ssmtp.conf && \ RUN chmod +x /usr/local/bin/start.sh && \
chmod +x /usr/local/bin/update_ssmtp.sh /usr/local/bin/start.sh && \
mkdir -p /var/www mkdir -p /var/www
# Work around an aufs bug related to directory permissions: # Work around an aufs bug related to directory permissions:
RUN mkdir -p /tmp && \ RUN mkdir -p /tmp && chmod 1777 /tmp
chmod 1777 /tmp
# Internal Port Expose # Internal Port Expose
EXPOSE 5762 EXPOSE 5762

View File

@ -1,33 +1,105 @@
#!/bin/bash #!/bin/bash
update_ssmtp.sh
cd /srv/ledgersmb cd /srv/ledgersmb
if [[ -n "$SSMTP_ROOT" ]]; then
echo "\$SSMTP_ROOT set; parameter is deprecated and will be ignored"
LSMB_HAVE_DEPRECATED=1
fi
if [[ -n "$SSMTP_FROMLINE_OVERRIDE" ]]; then
echo "\$SSMTP_FROMLINE_OVERRIDE set; parameter is deprecated and will be ignored"
LSMB_HAVE_DEPRECATED=1
fi
if [[ -n "$SSMTP_MAILHUB" ]]; then
echo "\$SSMTP_MAILHUB set; parameter is deprecated"
if [[ -z "$LSMB_MAIL_SMTPHOST" ]]; then
echo " Deriving \$LSMB_MAIL_SMTPHOST setting from \$SSMTP_MAILHUB"
LSMB_MAIL_SMTPHOST=${SSMTP_MAILHUB%:*}
fi
if [[ -z "$LSMB_MAIL_SMTPPORT" ]]; then
echo " Deriving \$LSMB_MAIL_SMTPPORT setting from \$SSMTP_MAILHUB"
LSMB_MAIL_SMTPPORT=${SSMTP_MAILHUB#*:}
fi
LSMB_HAVE_DEPRECATED=1
fi
if [[ -n "$SSMTP_HOSTNAME" ]]; then
echo "\$SSMTP_HOSTNAME set; parameter is deprecated"
if [[ -z "$LSMB_MAIL_SMTPSENDER_HOSTNAME" ]]; then
echo " Deriving \$LSMB_MAIL_SMTPSENDER_HOSTNAME setting from \$SSMTP_HOSTNAME"
LSMB_MAIL_SMTPSENDER_HOSTNAME=$SSMTP_HOSTNAME
fi
LSMB_HAVE_DEPRECATED=1
fi
if [[ -n "$SSMTP_USE_STARTTLS" ]]; then
echo "\$SSMTP_USE_STARTTLS set; parameter is deprecated"
if [[ -z "$LSMB_MAIL_SMTPTLS" ]]; then
echo " Deriving \$LSMB_MAIL_SMTPSENDER_HOSTNAME setting from \$SSMTP_USE_STARTTLS"
LSMB_MAIL_SMTPTLS=$SSMTP_USE_STARTTLS
fi
LSMB_HAVE_DEPRECATED=1
fi
if [[ -n "$SSMTP_AUTH_USER" ]]; then
echo "\$SSMTP_AUTH_USER set; parameter is deprecated"
if [[ -z "$LSMB_MAIL_SMTPUSER" ]]; then
echo " Deriving \$LSMB_MAIL_SMTPUSER setting from \$SSMTP_AUTH_USER"
LSMB_MAIL_SMTPUSER=$SSMTP_AUTH_USER
fi
LSMB_HAVE_DEPRECATED=1
fi
if [[ -n "$SSMTP_AUTH_PASS" ]]; then
echo "\$SSMTP_AUTH_PASS set; parameter is deprecated"
if [[ -z "$LSMB_MAIL_SMTPPASS" ]]; then
echo " Deriving \$LSMB_MAIL_SMTPPASS setting from \$SSMTP_AUTH_PASS"
LSMB_MAIL_SMTPPASS=$SSMTP_AUTH_PASS
fi
LSMB_HAVE_DEPRECATED=1
fi
if [[ -n "$SSMTP_AUTH_METHOD" ]]; then
echo "\$SSMTP_AUTH_METHOD set; parameter is deprecated"
if [[ -z "$LSMB_MAIL_SMTPAUTHMECH" ]]; then
echo " Deriving \$LSMB_MAIL_SMTPAUTHMECH setting from \$SSMTP_AUTH_METHOD"
LSMB_MAIL_SMTPAUTHMECH=$SSMTP_AUTH_METHOD
fi
LSMB_HAVE_DEPRECATED=1
fi
if [[ -n "$LSMB_HAVE_DEPRECATED" ]]; then
echo "!!! DEPRECATED \$SSMTP_* PARAMETERS WILL BE REMOVED in the 1.9 image!!!"
fi
if [[ ! -f ledgersmb.conf ]]; then if [[ ! -f ledgersmb.conf ]]; then
cat <<EOF >/tmp/ledgersmb.conf cat <<EOF >/tmp/ledgersmb.conf
[main] [main]
cache_templates = 1 cache_templates = 1
[database] [database]
host = $POSTGRES_HOST host = $POSTGRES_HOST
port = $POSTGRES_PORT port = $POSTGRES_PORT
default_db = $DEFAULT_DB default_db = $DEFAULT_DB
[mail] [mail]
sendmail = /usr/sbin/ssmtp ${LSMB_MAIL_SMTPHOST:+smtphost=$LSMB_MAIL_SMTPHOST
}${LSMB_MAIL_SMTPPORT:+smtpport=$LSMB_MAIL_SMTPPORT
}${LSMB_MAIL_SMTPSENDER_HOSTNAME:+smtpsender_hostname=$LSMB_MAIL_SMTPSENDER_HOSTNAME
}${LSMB_MAIL_SMTPTLS:+smtptls=$LSMB_MAIL_SMTPTLS
}${LSMB_MAIL_SMTPUSER:+smtpuser=$LSMB_MAIL_SMTPUSER
}${LSMB_MAIL_SMTPPASS:+smtppass=$LSMB_MAIL_SMTPPASS
}${LSMB_MAIL_SMTPAUTHMECH:+smtpauthmech=$LSMB_MAIL_SMTPAUTHMECH
}
EOF EOF
export LSMB_CONFIG_FILE='/tmp/ledgersmb.conf' export LSMB_CONFIG_FILE='/tmp/ledgersmb.conf'
fi fi
if [ ! -d "/tmp/ledgersmb" ]; then
mkdir -p /tmp/ledgersmb
fi
# start ledgersmb # start ledgersmb
# --preload-app allows application initialization to kill the entire # --preload-app allows application initialization to kill the entire
# starman instance (instead of just the worker, which will immediately # starman instance (instead of just the worker, which will immediately
# get restarted); it also has a positive effect on memory use # get restarted) on error; it also has a positive effect on memory use
exec starman --port 5762 --workers ${LSMB_WORKERS:-5} -I lib -I old/lib \ echo '--------- LEDGERSMB CONFIGURATION: ledgersmb.conf'
--preload-app bin/ledgersmb-server.psgi cat ${LSMB_CONFIG_FILE:-ledgersmb.conf}
echo '--------- LEDGERSMB CONFIGURATION --- END'
# ':5762:' suppresses an uninitialized variable warning in starman
# the last colon means "don't connect using tls"; without it, there's a warning
exec starman --listen :5762: --max-workers ${LSMB_WORKERS:-5} \
-I lib -I old/lib \
--preload-app bin/ledgersmb-server.psgi

View File

@ -1,18 +0,0 @@
#!/bin/bash
ConfiguredComment='# install script update_ssmtp.sh has configured ssmtp'
grep -qc "$ConfiguredComment" /etc/ssmtp/ssmtp.conf && {
echo "smtp configured."
exit
}
sed -i \
-e "s/\(root=\).*\$/\1$SSMTP_ROOT/g" \
-e "s/\(mailhub=\).*\$/\1$SSMTP_MAILHUB/g" \
-e "s/\(hostname=\).*\$/\1$SSMTP_HOSTNAME/g" \
/etc/ssmtp/ssmtp.conf
[ -z "$SSMTP_USE_STARTTLS" ] || echo "UseSTARTTLS=$SSMTP_USE_STARTTLS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SSMTP_AUTH_USER" ] || echo "AuthUser=$SSMTP_AUTH_USER" >> /etc/ssmtp/ssmtp.conf
[ -z "$SSMTP_AUTH_PASS" ] || echo "AuthPass=$SSMTP_AUTH_PASS" >> /etc/ssmtp/ssmtp.conf
[ -z "$SSMTP_AUTH_METHOD" ] || echo "AuthMethod=$SSMTP_AUTH_METHOD" >> /etc/ssmtp/ssmtp.conf
[ -z "$SSMTP_FROMLINE_OVERRIDE" ] || echo "FromLineOverride=$SSMTP_FROMLINE_OVERRIDE" >> /etc/ssmtp/ssmtp.conf
echo "$ConfiguredComment" >> /etc/ssmtp/ssmtp.conf