diff --git a/7.8.3/Dockerfile b/7.8.3/Dockerfile new file mode 100644 index 0000000..839c117 --- /dev/null +++ b/7.8.3/Dockerfile @@ -0,0 +1,38 @@ +FROM php:5.6-apache + +ENV DOWNLOAD_URL http://downloads.sourceforge.net/project/suitecrm/SuiteCRM-7.8.3.zip?r=&ts=1458855387&use_mirror=iweb +ENV DOWNLOAD_FILE suitecrm-7.8.3.zip +ENV EXTRACT_FOLDER SuiteCRM-7.8.3 +ENV WWW_FOLDER /var/www/html +ENV WWW_USER www-data +ENV WWW_GROUP www-data + +RUN apt-get update && apt-get upgrade -y && \ + apt-get install -y libcurl4-gnutls-dev libpng-dev libssl-dev libc-client2007e-dev libkrb5-dev unzip cron re2c python tree && \ + docker-php-ext-configure imap --with-imap-ssl --with-kerberos && \ + docker-php-ext-install mysql curl gd zip mbstring imap && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /tmp + +RUN curl -o $DOWNLOAD_FILE -L "${DOWNLOAD_URL}" && \ + unzip $DOWNLOAD_FILE && \ + rm $DOWNLOAD_FILE && \ + rm -rf ${WWW_FOLDER}/* && \ + cp -R ${EXTRACT_FOLDER}/* ${WWW_FOLDER}/ && \ + chown -R ${WWW_USER}:${WWW_GROUP} ${WWW_FOLDER}/* && \ + chown -R ${WWW_USER}:${WWW_GROUP} ${WWW_FOLDER} + +ADD php.ini /usr/local/etc/php/php.ini +ADD config_override.php.pyt /usr/local/src/config_override.php.pyt +ADD envtemplate.py /usr/local/bin/envtemplate.py +ADD init.sh /usr/local/bin/init.sh + +RUN chmod u+x /usr/local/bin/init.sh +RUN chmod u+x /usr/local/bin/envtemplate.py + +ADD crons.conf /etc/cron.d/crons.conf +RUN crontab /etc/cron.d/crons.conf + +EXPOSE 80 +ENTRYPOINT ["/usr/local/bin/init.sh"] diff --git a/7.8.3/config_override.php.pyt b/7.8.3/config_override.php.pyt new file mode 100644 index 0000000..02b5f42 --- /dev/null +++ b/7.8.3/config_override.php.pyt @@ -0,0 +1,17 @@ + diff --git a/7.8.3/crons.conf b/7.8.3/crons.conf new file mode 100644 index 0000000..96516ce --- /dev/null +++ b/7.8.3/crons.conf @@ -0,0 +1 @@ +* * * * * www-data /usr/local/bin/php -f /var/www/html/cron.php >> /var/log/cron.log 2>&1 diff --git a/7.8.3/envtemplate.py b/7.8.3/envtemplate.py new file mode 100644 index 0000000..a84eaa9 --- /dev/null +++ b/7.8.3/envtemplate.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +import os, sys, getopt +from string import Template + +def main(argv): + inputfile = '' + outputfile = '' + try: + opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="]) + except getopt.GetoptError: + print 'test.py -i -o ' + sys.exit(2) + for opt, arg in opts: + if opt == '-h': + print 'test.py -i -o ' + sys.exit() + elif opt in ("-i", "--ifile"): + inputfile = arg + elif opt in ("-o", "--ofile"): + outputfile = arg + + # Read all environment variables in and populate a case-insensitive + # dictionary for replacement + values = dict() + for k in os.environ: + v = os.environ.get(k) + values[k] = v + values[k.lower()] = v + + + + # Read the template + ifile = open(inputfile) + templatestr = open(inputfile).read() + ifile.close() + + out = Template(templatestr).substitute(values) + + print "Writing output to {}".format(outputfile) + print "===============================" + print out + + ofile = open(outputfile, "w") + ofile.write(out) + ofile.close() + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/7.8.3/init.sh b/7.8.3/init.sh new file mode 100644 index 0000000..69c4f0c --- /dev/null +++ b/7.8.3/init.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +set -e + +if [ -z "$DB_HOST_NAME" ]; then + export DB_HOST_NAME=$DB_PORT_3306_TCP_ADDR +fi + +if [ -z "$DB_TCP_PORT" ]; then + export DB_TCP_PORT=$DB_PORT_3306_TCP_PORT +fi + +if [ -z "$DB_USER_NAME" ]; then + export DB_USER_NAME=$DB_ENV_MYSQL_USER +fi + +if [ -z "$DB_PASSWORD" ]; then + export DB_PASSWORD=$DB_ENV_MYSQL_PASSWORD +fi + +if [ -z "$DATABASE_NAME" ]; then + export DATABASE_NAME=$DB_ENV_MYSQL_DATABASE +fi + +/usr/local/bin/envtemplate.py -i /usr/local/src/config_override.php.pyt -o /var/www/html/config_override.php +/usr/sbin/cron + +# Remove Apache PID lock file so apache can start next time +rm -f /run/apache2/apache2.pid + +# Start Apache +apachectl -DFOREGROUND diff --git a/7.8.3/php.ini b/7.8.3/php.ini new file mode 100644 index 0000000..5738540 --- /dev/null +++ b/7.8.3/php.ini @@ -0,0 +1 @@ +upload_max_filesize = 25M diff --git a/docker-compose.yml b/docker-compose.yml index 300d7ea..9592b89 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ suitecrm: - build: 7.5.3 + build: 7.8.3 ports: - "8080:80" links: