Skip to content

Instantly share code, notes, and snippets.

@nakato
Created February 2, 2017 09:08
Show Gist options
  • Save nakato/d2b6bffc7c16d0d237d0f4dde39f00b8 to your computer and use it in GitHub Desktop.
Save nakato/d2b6bffc7c16d0d237d0f4dde39f00b8 to your computer and use it in GitHub Desktop.
#!/bin/bash
source /config.sh
# Sleep slightly longer than RT to let RT come up before
# we try to run any cron jobs as some of them communicate
# with RT.
# The only one that matters is rt-mailgate, but it handles
# failures gracefully and will not drop messages if we fail
# to ingest them.
sleep 20
echo "Starting crond"
/usr/sbin/crond -f
FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
RUN set -x \
&& apt-get update \
&& apt-get install -y --no-install-recommends build-essential curl libmysqlclient-dev ca-certificates uwsgi uwsgi-plugin-psgi mysql-client cpanminus python python-pip python-setuptools python-wheel ssmtp \
&& apt-get install -y --no-install-recommends libapache-session-perl libcgi-emulate-psgi-perl libcgi-pm-perl libcgi-psgi-perl libconvert-color-perl libcrypt-eksblowfish-perl libcrypt-ssleay-perl libcrypt-x509-perl libcss-minifier-xs-perl libcss-squish-perl libdata-guid-perl libdata-ical-perl libdata-page-perl libdate-extract-perl libdate-manip-perl libdatetime-format-natural-perl libdbd-mysql-perl libdbi-perl libdbix-searchbuilder-perl libemail-abstract-perl libemail-address-list-perl libemail-address-perl libfcgi-perl libencode-perl libfcgi-procmanager-perl libfile-sharedir-install-perl libfile-sharedir-perl libfile-which-perl libgd-graph-perl libgd-text-perl libgnupg-interface-perl libgraphviz-perl libhtml-formattext-withlinks-andtables-perl libhtml-mason-perl libhtml-mason-psgihandler-perl libhtml-quoted-perl libhtml-rewriteattributes-perl libhtml-scrubber-perl libhttp-message-perl libipc-run3-perl libipc-signal-perl libjavascript-minifier-xs-perl libjson-perl liblocale-maketext-fuzzy-perl liblocale-maketext-lexicon-perl liblocale-po-perl liblog-dispatch-perl liblog-dispatch-perl-perl libmailtools-perl libmime-tools-perl libmime-types-perl libmodule-versions-report-perl libmodule-signature-perl libmodule-versions-report-perl libmojolicious-perl libnet-cidr-perl libnet-ip-perl libnet-ldap-perl libperlio-eol-perl libplack-perl libregexp-common-email-address-perl libregexp-common-net-cidr-perl libregexp-common-perl libregexp-ipv6-perl librole-basic-perl libscope-upper-perl libserver-starter-perl libset-tiny-perl libstring-shellquote-perl libsymbol-global-name-perl libterm-readkey-perl libtext-password-pronounceable-perl libtext-quoted-perl libtext-template-perl libtext-wikiformat-perl libtext-wrapper-perl libtime-parsedate-perl libtime-modules-perl libtree-simple-perl libuniversal-require-perl libwww-mechanize-perl libxml-rss-perl libxml-simple-perl perl-doc starlet graphviz \
&& rm -rf /var/lib/apt/lists/*
RUN set -x \
&& cpanm Mozilla::CA Business::Hours Data::Page::Pageset Amazon::S3
ENV RT_VERSION 4.4.1
ENV DCRON_VERSION 4.5
ENV GETMAIL_VERSION 4.51.0
RUN set -x \
&& mkdir -p /opt/src \
&& cd /opt/src \
&& curl -o rt.tar.gz "https://download.bestpractical.com/pub/rt/release/rt-$RT_VERSION.tar.gz" \
&& tar xf rt.tar.gz && rm rt.tar.gz && cd rt-$RT_VERSION \
&& /opt/src/rt-$RT_VERSION/configure --enable-graphviz --enable-gpg --enable-smime --enable-gd \
&& make testdeps \
&& make install \
&& rm -rf /opt/src
# Crappy way of getting Google Cloud Storage external storage setup
COPY conf/AmazonS3.pm /opt/rt4/lib/RT/ExternalStorage/AmazonS3.pm
RUN set -x \
&& cpanm RT::Extension::LDAPImport
RUN set -x \
&& mkdir -p /opt/src \
&& cd /opt/src \
&& curl -o dcron.tar.gz "http://www.jimpryor.net/linux/releases/dcron-$DCRON_VERSION.tar.gz" \
&& tar xf dcron.tar.gz && rm dcron.tar.gz && cd dcron-$DCRON_VERSION \
&& make PREFIX=/usr CRONTAB_GROUP=users && make && make install \
&& rm -rf /opt/src
RUN set -x \
&& mkdir -p /opt/src \
&& cd /opt/src \
&& curl -o getmail.tar.gz "http://pyropus.ca/software/getmail/old-versions/getmail-$GETMAIL_VERSION.tar.gz" \
&& tar xf getmail.tar.gz && rm getmail.tar.gz && cd getmail-$GETMAIL_VERSION \
&& pip install . \
&& rm -rf /opt/src \
&& mkdir /root/.getmail
RUN set -x \
&& chmod -R u+rwX,go-w,go+rX /opt/rt4/share/html /opt/rt4/local/html /opt/rt4/share/po /opt/rt4/local/po /opt/rt4/share/static /opt/rt4/local/static \
&& chown -R root:bin /opt/rt4/share/html /opt/rt4/local/html /opt/rt4/share/po /opt/rt4/local/po /opt/rt4/share/static /opt/rt4/local/static \
&& chmod 0770 /opt/rt4/var/mason_data /opt/rt4/var/session_data \
&& chown -R www-data:www-data /opt/rt4/var/mason_data /opt/rt4/var/session_data
RUN set -x \
&& rm -rf /etc/cron.daily /etc/cron.weekly
COPY config.sh /config.sh
COPY rt.sh /rt.sh
COPY cron.sh /cron.sh
COPY getmail.sh /getmail.sh
#!/bin/bash
cd /tmp
/usr/local/bin/getmail -g /root/.getmail -r getmailrc*
#!/bin/bash
source /config.sh
until echo "SHOW STATUS" | mysql -h 127.0.0.1 -P 3306 -u $RTDBUser --password=$RTDBPass --connect_timeout=1
do
echo "No MySQL - Sleeping"
sleep 1
done
exec /usr/bin/uwsgi --plugin psgi -p 3 --socket 0.0.0.0:8080 --psgi /opt/rt4/sbin/rt-server
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment