Add docker utilities, allow docker and non-docker codebase to coexist, add support for auto-installing fixtures.
This commit is contained in:
parent
4e136a1cef
commit
e8a03cfa07
|
@ -19,6 +19,8 @@ app/models/Proxy/*.php
|
|||
|
||||
# Local development files.
|
||||
app/.env
|
||||
/util/fixtures/*
|
||||
!/util/fixtures/.gitkeep
|
||||
|
||||
# Composer-generated content
|
||||
/vendor/
|
||||
|
|
|
@ -34,7 +34,10 @@ return function (\Slim\Container $di, \App\Config $config) {
|
|||
try {
|
||||
$config = $di['config'];
|
||||
$options = $config->application->doctrine->toArray();
|
||||
$options['conn'] = $config->db->toArray();
|
||||
|
||||
$options['conn'] = (APP_INSIDE_DOCKER) ?
|
||||
$config->docker->db->toArray() :
|
||||
$config->db->toArray();
|
||||
|
||||
// Fetch and store entity manager.
|
||||
$config = new \Doctrine\ORM\Configuration;
|
||||
|
@ -96,7 +99,10 @@ return function (\Slim\Container $di, \App\Config $config) {
|
|||
// Caching
|
||||
$di['cache_driver'] = function ($di) {
|
||||
$config = $di['config'];
|
||||
$cache_config = $config->cache->toArray();
|
||||
|
||||
$cache_config = (APP_INSIDE_DOCKER) ?
|
||||
$config->docker->cache->toArray() :
|
||||
$config->cache->toArray();
|
||||
|
||||
switch ($cache_config['cache']) {
|
||||
case 'redis':
|
||||
|
@ -160,7 +166,10 @@ return function (\Slim\Container $di, \App\Config $config) {
|
|||
// InfluxDB
|
||||
$di['influx'] = function ($di) {
|
||||
$config = $di['config'];
|
||||
$opts = $config->influx->toArray();
|
||||
|
||||
$opts = (APP_INSIDE_DOCKER) ?
|
||||
$config->docker->influx->toArray() :
|
||||
$config->influx->toArray();
|
||||
|
||||
$influx = new \InfluxDB\Client($opts['host'], $opts['port']);
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
/**
|
||||
* Backend cache configuration.
|
||||
*/
|
||||
|
||||
return [
|
||||
// Valid options are:
|
||||
// ephemeral - Uses in-memory cache that expires at page request.
|
||||
// memcached - Uses libmemcached and 'memcached' settings below.
|
||||
// redis - Uses phpredis and 'redis' settings below.
|
||||
// file - Uses flat-file storage and 'file' settings below.
|
||||
'cache' => 'file',
|
||||
|
||||
// Flatfile configuration
|
||||
'file' => [
|
||||
'path' => APP_INCLUDE_CACHE . DIRECTORY_SEPARATOR,
|
||||
],
|
||||
|
||||
// Redis configuration
|
||||
'redis' => [
|
||||
'servers' => [
|
||||
[
|
||||
'server' => 'localhost',
|
||||
'port' => 6379, // default: 6379
|
||||
],
|
||||
],
|
||||
|
||||
// 'password' => '', // Must be commented out to have no authentication
|
||||
'database' => 0,
|
||||
],
|
||||
|
||||
// Memcached configuration
|
||||
'memcached' => [
|
||||
'servers' => [
|
||||
[
|
||||
'server' => 'memcached',
|
||||
'port' => 11211, // default: 11211
|
||||
'weight' => 1,
|
||||
],
|
||||
],
|
||||
'extension' => 'memcached', // Use libmemcached instead of memcache
|
||||
],
|
||||
|
||||
];
|
|
@ -26,7 +26,7 @@ class LiquidSoap extends BackendAbstract
|
|||
'set("init.daemon.pidfile.path","' . $config_path . '/liquidsoap.pid")',
|
||||
'set("log.file.path","' . $config_path . '/liquidsoap.log")',
|
||||
'set("server.telnet",true)',
|
||||
'set("server.telnet.bind_addr","127.0.0.1")',
|
||||
'set("server.telnet.bind_addr","'.(APP_INSIDE_DOCKER ? '0.0.0.0' : '127.0.0.1').'")',
|
||||
'set("server.telnet.port", ' . $this->_getTelnetPort() . ')',
|
||||
'set("server.telnet.reverse_dns",false)',
|
||||
'set("harbor.bind_addr","0.0.0.0")',
|
||||
|
@ -372,7 +372,7 @@ class LiquidSoap extends BackendAbstract
|
|||
|
||||
protected function _getTelnetPort()
|
||||
{
|
||||
return (8500 + (($this->station->id - 1) * 10));
|
||||
return (8000 + (($this->station->id - 1) * 10) + 4);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -15,4 +15,5 @@
|
|||
roles:
|
||||
- docker-install
|
||||
- composer
|
||||
- azuracast-db
|
||||
- azuracast-db
|
||||
- { role: azuracast-fixtures, when: testing_mode == false and app_env == 'development' }
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
- name: Find fixture ZIP files
|
||||
find:
|
||||
paths: "{{ util_base }}/fixtures"
|
||||
patterns: "*.zip"
|
||||
recurse: yes
|
||||
register: fixture_zip_files
|
||||
|
||||
- name: Extract fixture ZIP files
|
||||
unarchive:
|
||||
src: "{{ item.path }}"
|
||||
dest: "{{ app_base }}/stations"
|
||||
owner: azuracast
|
||||
with_items: "{{ fixture_zip_files.files }}"
|
||||
when: fixture_zip_files.matched > 0
|
||||
|
||||
- name: Find fixture SQL files
|
||||
find:
|
||||
paths: "{{ util_base }}/fixtures"
|
||||
patterns: "*.sql"
|
||||
recurse: yes
|
||||
register: fixture_sql_files
|
||||
|
||||
- name: Import fixture SQL files
|
||||
become: true
|
||||
become_user: azuracast
|
||||
shell: "php {{ util_base }}/cli.php dbal:import {{ item.path }}"
|
||||
with_items: "{{ fixture_sql_files.files }}"
|
||||
when: fixture_sql_files.matched > 0
|
||||
|
||||
- name: Clear AzuraCast Cache and Restart Stations
|
||||
become: true
|
||||
become_user: azuracast
|
||||
shell: php {{ util_base }}/cli.php cache:clear && php {{ util_base }}/cli.php radio:restart
|
||||
when: fixture_zip_files.matched > 0 or fixture_sql_files.matched > 0
|
|
@ -36,13 +36,4 @@
|
|||
database: "stations"
|
||||
retentions: "1h:1h,1d:1d"
|
||||
measurements: [{'measurement':':MEASUREMENT', 'fields': ['min(value) AS min','mean(value) AS value','max(value) AS max']}]
|
||||
prune: true
|
||||
|
||||
- name: Write InfluxDB configuration
|
||||
become: true
|
||||
template: src=influx.conf.php.j2 dest="{{ www_base }}/app/config/influx.conf.php" owner=azuracast group=azuracast mode=0644 force=yes
|
||||
|
||||
- name: Write DB configuration
|
||||
become: true
|
||||
template: src=db.conf.php.j2 dest="{{ www_base }}/app/config/db.conf.php" owner=azuracast group=azuracast mode=0644 force=yes
|
||||
register: azuracast_db_created
|
||||
prune: true
|
|
@ -3,7 +3,7 @@ FROM ubuntu:xenial
|
|||
# Install essential packages
|
||||
RUN apt-get update && \
|
||||
apt-get install -q -y apt-transport-https curl wget tar python-software-properties \
|
||||
software-properties-common pwgen whois lnav sudo
|
||||
software-properties-common pwgen whois lnav sudo zip
|
||||
|
||||
# Set directory permissions
|
||||
RUN mkdir -p /var/azuracast/www_tmp
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ansible-playbook /var/azuracast/www/util/ansible/docker_install.yml --inventory=/var/azuracast/www/util/ansible/hosts
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
--dev)
|
||||
APP_ENV="development"
|
||||
shift
|
||||
;;
|
||||
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
APP_ENV="${APP_ENV:-production}"
|
||||
|
||||
echo "Updating AzuraCast (Environment: $APP_ENV)"
|
||||
|
||||
ansible-playbook /var/azuracast/www/util/ansible/docker_install.yml --inventory=/var/azuracast/www/util/ansible/hosts --extra-vars "app_env=$APP_ENV"
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
docker-compose kill
|
||||
docker stop $(docker ps -a -q)
|
||||
docker rm $(docker ps -a -q)
|
||||
docker volume prune -f
|
||||
|
||||
docker-compose up -d --build
|
||||
docker-compose run web azuracast_install --dev
|
Loading…
Reference in New Issue