diff --git a/Dockerfile b/Dockerfile index 74bba7f..4dcad29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,8 @@ FROM php:7.2-apache # Use the default production configuration RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" +RUN docker-php-ext-install pdo_mysql + # Enable rewrite module for httpd. RUN ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load diff --git a/api/DBconnect.php b/api/DBconnect.php index 89996d1..e338acf 100644 --- a/api/DBconnect.php +++ b/api/DBconnect.php @@ -9,10 +9,10 @@ class DBconnect { - private static $host = getenv('DB_HOST') ?: "localhost"; - private static $user = getenv('DB_USER') ?: "nermin"; - private static $password = getenv('DB_PASS') ?: ""; - private static $schema = getenv('DB_SCHEMA') ?: "dialectsdb"; + private static $host = "localhost"; + private static $user = "nermin"; + private static $password = ""; + private static $schema = "dialectsdb"; private static $instance = null; private function __construct() { @@ -31,6 +31,21 @@ class DBconnect { * @return PDO instance */ public static function getInstance() { + + // Check for config overrides via enviroment variables. + if (getenv('DB_HOST')) { + self::$host = getenv('DB_HOST'); + } + if (getenv('DB_USER')) { + self::$user = getenv('DB_USER'); + } + if (getenv('DB_PASS')) { + self::$password = getenv('DB_PASS'); + } + if (getenv('DB_SCHEMA')) { + self::$schema = getenv('DB_SCHEMA'); + } + if (!self::$instance) { $config = "mysql:host=" . self::$host . ";dbname=" . self::$schema; diff --git a/docker-compose.yml b/docker-compose.yml index 6e9a6d0..1175a91 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: ports: - "5000:80" volumes: - - :/var/lib/www/iknb/resources/audio + - :/var/www/html/resources/audio environment: DB_HOST: db DB_USER: nermin diff --git a/index.html b/index.html index 1027420..6564092 100644 --- a/index.html +++ b/index.html @@ -28,10 +28,10 @@ --> - - - - + + + +