From dd4973c2c86aeb1aa5e7ffde9f74076d872d4f4f Mon Sep 17 00:00:00 2001 From: Alex Brandt Date: Tue, 28 Oct 2014 13:39:58 -0500 Subject: Add Dockerfile. --- Dockerfile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..e1d4b6e77 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM debian:latest +MAINTAINER Alex Brandt + +EXPOSE 80 443 + +RUN apt-get -qq update +RUN apt-get install -qq apache2-mpm-event + +RUN sed -e 's|/var/www|&/public_html|' -e 's/\(Log \+\)[^ ]\+/\1"|cat"/' -i /etc/apache2/sites-available/default + +RUN a2enmod expires +RUN a2enmod headers + +RUN apt-get install -qq php5 php-pear php5-mysql php5-pgsql php5-sqlite +RUN pear install mail_mime mail_mimedecode net_smtp2-beta net_idna2-beta auth_sasl2-beta net_sieve crypt_gpg + +RUN rm -rf /var/www +ADD . /var/www + +RUN echo -e ' /var/www/config/config.inc.php +RUN rm -rf /var/www/installer + +RUN . /etc/apache2/envvars && chown -R ${APACHE_RUN_USER}:${APACHE_RUN_GROUP} /var/www/temp /var/www/logs + +ENTRYPOINT [ "/usr/sbin/apache2ctl", "-D", "FOREGROUND" ] +CMD [ "-k", "start" ] -- cgit v1.2.3 From 616f88a843b6adfe75a0bc8ccf06b37606be63c2 Mon Sep 17 00:00:00 2001 From: Alex Brandt Date: Fri, 31 Oct 2014 19:49:04 -0500 Subject: Add SSL support to Dockerfile. --- Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Dockerfile b/Dockerfile index e1d4b6e77..4db07cf0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,9 +7,17 @@ RUN apt-get -qq update RUN apt-get install -qq apache2-mpm-event RUN sed -e 's|/var/www|&/public_html|' -e 's/\(Log \+\)[^ ]\+/\1"|cat"/' -i /etc/apache2/sites-available/default +RUN a2ensite default + +RUN sed -e 's|/var/www|&/public_html|' -e 's/\(Log \+\)[^ ]\+/\1"|cat"/' -i /etc/apache2/sites-available/default-ssl +RUN sed -e '/SSLCertificateKeyFile/s|ssl-cert-snakeoil.key|ssl-cert.key|' -e '/SSLCertificateFile/s|ssl-cert-snakeoil.pem|ssl-cert.pem|' -i /etc/apache2/sites-available/default-ssl +RUN ln -snf ssl-cert-snakeoil.pem /etc/ssl/certs/ssl-cert.pem +RUN ln -snf ssl-cert-snakeoil.key /etc/ssl/private/ssl-cert.key +RUN a2ensite default-ssl RUN a2enmod expires RUN a2enmod headers +RUN a2enmod ssl RUN apt-get install -qq php5 php-pear php5-mysql php5-pgsql php5-sqlite RUN pear install mail_mime mail_mimedecode net_smtp2-beta net_idna2-beta auth_sasl2-beta net_sieve crypt_gpg -- cgit v1.2.3 From e4b9910a322bbf0e0c919fe4bc2f133294c4cd69 Mon Sep 17 00:00:00 2001 From: Alex Brandt Date: Wed, 29 Oct 2014 22:46:50 -0500 Subject: Add environment variable reading to configuration. Docker prefers to pass parameters via environment variables. This allows the environment variables to be checked and if a value exists it will override the default. --- program/lib/Roundcube/rcube_config.php | 106 ++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) diff --git a/program/lib/Roundcube/rcube_config.php b/program/lib/Roundcube/rcube_config.php index 53409f26f..e9a16c061 100644 --- a/program/lib/Roundcube/rcube_config.php +++ b/program/lib/Roundcube/rcube_config.php @@ -93,6 +93,103 @@ class rcube_config } + /** + * @brief Guess the type the string may fit into. + * + * Look inside the string to determine what type might be best as a container. + * + * @param $value The value to inspect + * + * @return The guess at the type. + */ + private function guess_type($value) { + $_ = 'string'; + + // array requires hint to be passed. + + if (preg_match('/^[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?$/', $value) !== False) { + $_ = 'double'; + } else if (preg_match('/^\d+$/', $value) !== False) { + $_ = 'integer'; + } else if (preg_match('/(t(rue)?)|(f(alse)?)/i', $value) !== False) { + $_ = 'boolean'; + } + + return $_; + } + + + /** + * @brief Parse environment variable into PHP type. + * + * Perform an appropriate parsing of the string to create the desired PHP type. + * + * @param $string String to parse into PHP type + * @param $type Type of value to return + * + * @return Appropriately typed interpretation of $string. + */ + private function parse_env($string, $type) { + console("parse $string into $type"); + + $_ = $string; + + switch ($type) { + case 'boolean': + $_ = (boolean) $_; + break; + case 'integer': + $_ = (integer) $_; + break; + case 'double': + $_ = (double) $_; + break; + case 'string': + break; + case 'array': + $_ = json_decode($_, true); + break; + case 'object': + $_ = json_decode($_, false); + break; + case 'resource': + case 'NULL': + default: + $_ = $this->parse_env($_, $this->guess_type($_)); + } + + return $_; + } + + + /** + * @brief Get environment variable value. + * + * Retrieve an environment variable's value or if it's not found, return the + * provided default value. + * + * @param $varname Environment variable name + * @param $default_value Default value to return if necessary + * @param $type Type of value to return + * + * @return Value of the environment variable or default if not found. + */ + private function getenv_default($varname, $default_value, $type = null) { + $_ = getenv($varname); + + if ($_ === False) { + $_ = $default_value; + } else { + if (is_null($type)) { + $type = gettype($default_value); + } + $_ = $this->parse_env($_, $type); + } + + return $_; + } + + /** * Load config from local config file * @@ -294,6 +391,8 @@ class rcube_config $result = explode(',', $result); } + $result = $this->getenv_default('ROUNDCUBE_' . strtoupper($name), $result) + $plugin = $rcube->plugins->exec_hook('config_get', array( 'name' => $name, 'default' => $def, 'result' => $result)); @@ -360,9 +459,14 @@ class rcube_config */ public function all() { + $props = $this->prop; + + foreach ($props as $prop_name => $prop_value) + $props[$prop_name] = $this->getenv_default('ROUNDCUBE_' . strtoupper($prop_name), $prop_value); + $rcube = rcube::get_instance(); $plugin = $rcube->plugins->exec_hook('config_get', array( - 'name' => '*', 'result' => $this->prop)); + 'name' => '*', 'result' => $props)); return $plugin['result']; } -- cgit v1.2.3