Use environment variables for changing Docker things.

This commit is contained in:
Buster "Silver Eagle" Neece 2018-02-23 14:28:05 -06:00
parent 56f7d577cd
commit 411b2cfcbe
4 changed files with 37 additions and 11 deletions

View File

@ -26,12 +26,14 @@ define('APP_INCLUDE_TEMP', APP_INCLUDE_ROOT . '/../www_tmp');
define('APP_INCLUDE_CACHE', APP_INCLUDE_TEMP . '/cache');
// Set up application environment.
if (file_exists(APP_INCLUDE_BASE.'/env.ini')) {
if (APP_INSIDE_DOCKER) {
$_ENV = getenv();
} else if (file_exists(APP_INCLUDE_BASE.'/env.ini')) {
$_ENV = array_merge($_ENV, parse_ini_file(APP_INCLUDE_BASE.'/env.ini'));
}
// Application environment.
define('APP_APPLICATION_ENV', $_ENV['application_env'] ?? 'production');
define('APP_APPLICATION_ENV', $_ENV['application_env'] ?? $_ENV['APPLICATION_ENV'] ?? 'production');
define('APP_IN_PRODUCTION', APP_APPLICATION_ENV === 'production');
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {

View File

@ -61,11 +61,11 @@ return function (\Slim\Container $di, $settings) {
];
if (APP_INSIDE_DOCKER) {
$options['conn']['host'] = 'mariadb';
$options['conn']['port'] = 3306;
$options['conn']['dbname'] = 'azuracast';
$options['conn']['user'] = 'azuracast';
$options['conn']['password'] = 'azur4c457';
$options['conn']['host'] = $_ENV['MYSQL_HOST'] ?? 'mariadb';
$options['conn']['port'] = $_ENV['MYSQL_PORT'] ?? 3306;
$options['conn']['dbname'] = $_ENV['MYSQL_DATABASE'] ?? 'azuracast';
$options['conn']['user'] = $_ENV['MYSQL_USER'] ?? 'azuracast';
$options['conn']['password'] = $_ENV['MYSQL_PASSWORD'] ?? 'azur4c457';
} else {
$options['conn']['host'] = $_ENV['db_host'] ?? 'localhost';
$options['conn']['port'] = $_ENV['db_port'] ?? '3306';

View File

@ -8,9 +8,19 @@ services:
web:
build:
context: ../docker-azuracast-web
environment:
APPLICATION_ENV: "development"
volumes:
- .:/var/azuracast/www
cli:
environment:
APPLICATION_ENV: "development"
cron:
environment:
APPLICATION_ENV: "development"
nginx:
build:
context: ../docker-azuracast-nginx

View File

@ -1,5 +1,16 @@
version: '2'
# Modify variables that are passed into the Docker containers here.
x-azuracast-env:
&default-environment
APPLICATION_ENV: "production" # "production" or "development"
MYSQL_HOST: "mariadb" # You can change this if you plan to connect to an external DB host.
MYSQL_PORT: 3306 # ^
MYSQL_USER: "azuracast" # Once the database has been installed, don't change this.
MYSQL_PASSWORD: "azur4c457" # ^
MYSQL_DATABASE: "azuracast" # ^
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
services:
nginx:
image: azuracast/azuracast_nginx:latest
@ -29,10 +40,7 @@ services:
volumes:
- db_data:/var/lib/mysql
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_USER=azuracast
- MYSQL_PASSWORD=azur4c457
- MYSQL_DATABASE=azuracast
<< : *default-environment
restart: always
influxdb:
@ -52,6 +60,8 @@ services:
- influxdb
- stations
- redis
environment:
<< : *default-environment
volumes:
- www_data:/var/azuracast/www
- tmp_data:/var/azuracast/www_tmp
@ -68,6 +78,8 @@ services:
- influxdb
- stations
- redis
environment:
<< : *default-environment
command: 'cron && tail -f /var/log/cron.log'
restart: always
@ -80,6 +92,8 @@ services:
- influxdb
- stations
- redis
environment:
<< : *default-environment
user: 'azuracast'
working_dir: '/var/azuracast/www'
command: 'bash'