server: add Dockerfile and environment variables
The Dockerfile (and docker-compose) simplify the server's deployment. The environment variables avoid secrets in the code.
This commit is contained in:
@ -7,20 +7,14 @@ class database
|
||||
private static $instance = null;
|
||||
private $conn;
|
||||
|
||||
private $host = 'localhost';
|
||||
private $user = 'root';
|
||||
private $pass = '';
|
||||
private $name = 'fe_charts';
|
||||
private $port = '';
|
||||
|
||||
// The db connection is established in the private constructor.
|
||||
private function __construct()
|
||||
{
|
||||
try {
|
||||
$this->conn = new PDO(
|
||||
"mysql:host={$this->host};dbname={$this->name};port={$this->port}",
|
||||
$this->user,
|
||||
$this->pass
|
||||
'mysql:host=' . getenv('MYSQL_HOST') . ';dbname=' . getenv('MYSQL_DATABASE') . ';port=' . getenv('MYSQL_PORT'),
|
||||
getenv('MYSQL_USER'),
|
||||
getenv('MYSQL_PASSWORD')
|
||||
);
|
||||
} catch (PDOException $e) {
|
||||
die('Connection failed: ' . $e->getMessage());
|
||||
|
Reference in New Issue
Block a user