diff --git a/Dockerfile b/Dockerfile index f195d39..9310d5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,8 @@ RUN set -xe && \ apk update && apk upgrade && \ apk add --no-cache --virtual=run-deps \ nginx git ca-certificates curl \ - php5 php5-fpm php5-curl php5-dom php5-gd php5-json php5-mcrypt php5-pcntl php5-pdo php5-pdo_pgsql php5-pgsql php5-posix + php5 php5-fpm php5-curl php5-dom php5-gd php5-json php5-mcrypt php5-pcntl \ + php5-pdo php5-pdo_pgsql php5-pgsql php5-pdo_mysql php5-mysql php5-mysqli php5-posix # Add user www-data for php-fpm # 82 is the standard uid/gid for "www-data" in Alpine diff --git a/README.md b/README.md index 47542c8..e379eea 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,12 @@ default configuration, which can be changed by passing the following additional -e DB_PASS=ttrss ``` +#### Run on MySql + +```bash +-e DB_TYPE=mysql +``` + ### Database user When you run TT-RSS it will check your database setup. If it can not connect using the above diff --git a/root/srv/ttrss-configure-db.php b/root/srv/ttrss-configure-db.php index c0e1cb3..a4688d5 100644 --- a/root/srv/ttrss-configure-db.php +++ b/root/srv/ttrss-configure-db.php @@ -10,6 +10,11 @@ $conffile = $confpath . 'config.php'; $ename = 'DB'; $eport = 5432; +$db_type = env('DB_TYPE','pgsql'); +if ($db_type == 'mysql'){ + $eport = 3306; +} + echo 'Configuring database for: ' . $conffile . PHP_EOL; // check DB_NAME, which will be set automatically for a linked "db" container @@ -18,7 +23,7 @@ if (!env($ename . '_PORT', '')) { } $config = array(); -$config['DB_TYPE'] = 'pgsql'; +$config['DB_TYPE'] = $db_type; $config['DB_HOST'] = env($ename . '_PORT_' . $eport . '_TCP_ADDR'); $config['DB_PORT'] = env($ename . '_PORT_' . $eport . '_TCP_PORT'); diff --git a/root/srv/ttrss-configure-plugin-mobilize.php b/root/srv/ttrss-configure-plugin-mobilize.php index 7376574..47954e6 100644 --- a/root/srv/ttrss-configure-plugin-mobilize.php +++ b/root/srv/ttrss-configure-plugin-mobilize.php @@ -5,6 +5,11 @@ include '/srv/ttrss-utils.php'; $ename = 'DB'; $eport = 5432; + +$db_type = env('DB_TYPE','pgsql'); +if ($db_type == 'mysql'){ + $eport = 3306; +} $confpath = '/var/www/ttrss/config.php'; // check DB_NAME, which will be set automatically for a linked "db" container @@ -13,7 +18,7 @@ if (!env($ename . '_PORT', '')) { } $config = array(); -$config['DB_TYPE'] = 'pgsql'; +$config['DB_TYPE'] = $db_type; $config['DB_HOST'] = env($ename . '_PORT_' . $eport . '_TCP_ADDR'); $config['DB_PORT'] = env($ename . '_PORT_' . $eport . '_TCP_PORT'); @@ -32,7 +37,7 @@ try { } catch (PDOException $e) { echo 'Database table for mobilize plugin not found, applying schema... ' . PHP_EOL; - $schema = file_get_contents('/srv/ttrss-plugin-mobilize.pgsql'); + $schema = file_get_contents('/srv/ttrss-plugin-mobilize.'.$db_type); $schema = preg_replace('/--(.*?);/', '', $schema); $schema = preg_replace('/[\r\n]/', ' ', $schema); $schema = trim($schema, ' ;'); diff --git a/root/srv/ttrss-plugin-mobilize.mysql b/root/srv/ttrss-plugin-mobilize.mysql new file mode 100644 index 0000000..1a05ef0 --- /dev/null +++ b/root/srv/ttrss-plugin-mobilize.mysql @@ -0,0 +1,9 @@ +CREATE TABLE plugin_mobilize_feeds ( id int NOT NULL, owner_uid int NOT NULL, mobilizer_id int NOT NULL, PRIMARY KEY (id,owner_uid) ); +CREATE TABLE plugin_mobilize_mobilizers ( id int NOT NULL, description varchar(255) NOT NULL, url varchar(1000) NOT NULL, PRIMARY KEY (id) ) ; + +INSERT INTO plugin_mobilize_mobilizers ( id, description, url) VALUES +(0, 'Readability', 'http://www.readability.com/m?url=%s'), +(1, 'Instapaper', 'http://www.instapaper.com/m?u=%s'), +(2, 'Google Mobilizer', 'http://www.google.com/gwt/x?u=%s'), +(3, 'Original Stripped', 'http://strip=%s'), +(4, 'Original', '%s'); diff --git a/root/srv/ttrss-utils.php b/root/srv/ttrss-utils.php index 4d90903..935e159 100644 --- a/root/srv/ttrss-utils.php +++ b/root/srv/ttrss-utils.php @@ -26,7 +26,12 @@ function dbconnect($config) $dsn .= $d . '=' . $config['DB_' . $h] . ';'; } } - $pdo = new \PDO($dsn); + echo($dsn); + if ($config['DB_TYPE'] == 'pgsql'){ + $pdo = new \PDO($dsn); + } else { + $pdo = new \PDO($dsn, $config['DB_USER'], $config['DB_PASS']); + } $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $pdo; }