Browse Source

First working docker version.

master
mihasinkec 11 months ago
parent
commit
bee8e58982
  1. 2
      Dockerfile
  2. 23
      api/DBconnect.php
  3. 2
      docker-compose.yml
  4. 10
      index.html

2
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

23
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;

2
docker-compose.yml

@ -6,7 +6,7 @@ services:
ports:
- "5000:80"
volumes:
- <pot do zvočnih datotek>:/var/lib/www/iknb/resources/audio
- <pot do zvočnih datotek>:/var/www/html/resources/audio
environment:
DB_HOST: db
DB_USER: nermin

10
index.html

@ -28,10 +28,10 @@
<script src="vendor/ui-leaflet.js"></script>
-->
<script src="http://angular-ui.github.io/ui-leaflet/bower_components/leaflet/dist/leaflet.js"></script>
<script src="http://angular-ui.github.io/ui-leaflet/bower_components/angular-simple-logger/dist/angular-simple-logger.js"></script>
<script src="http://angular-ui.github.io/ui-leaflet/dist/ui-leaflet.min.js"></script>
<link href="http://angular-ui.github.io/ui-leaflet/bower_components/leaflet/dist/leaflet.css" rel="stylesheet" />
<script src="https://angular-ui.github.io/ui-leaflet/bower_components/leaflet/dist/leaflet.js"></script>
<script src="https://angular-ui.github.io/ui-leaflet/bower_components/angular-simple-logger/dist/angular-simple-logger.js"></script>
<script src="https://angular-ui.github.io/ui-leaflet/dist/ui-leaflet.min.js"></script>
<link href="https://angular-ui.github.io/ui-leaflet/bower_components/leaflet/dist/leaflet.css" rel="stylesheet" />
<script src="vendor/leaflet.pattern.js"></script>
<!--<script src="vendor/leaflet.extra-markers.min.js"></script>
@ -68,4 +68,4 @@
<app></app>
</body>
</html>
</html>
Loading…
Cancel
Save