Move to a unified Web container.

This commit is contained in:
Buster "Silver Eagle" Neece 2019-01-14 05:36:17 -06:00
parent fefbb5d573
commit 6fc1e1e8ea
13 changed files with 65 additions and 186 deletions

View File

@ -2,9 +2,14 @@ version: '2.2'
services:
web:
image: azuracast/azuracast_web:latest
image: azuracast/azuracast_web_v2:latest
build:
context: ../docker-azuracast-web
context: ../docker-azuracast-web-v2
# Want to customize the HTTP/S ports? Follow the instructions here:
# https://github.com/AzuraCast/AzuraCast/blob/master/SUPPORT.md#use-non-standard-ports
ports:
- '${AZURACAST_HTTP_PORT:-80}:80'
- '${AZURACAST_HTTPS_PORT:-443}:443'
depends_on:
- mariadb
- influxdb
@ -12,39 +17,18 @@ services:
- redis
env_file: azuracast.env
environment: &default-environment
AZURACAST_DC_REVISION: 4
AZURACAST_DC_REVISION: 5
volumes:
- letsencrypt:/etc/letsencrypt
- .:/var/azuracast/www
- tmp_data:/var/azuracast/www_tmp
- station_data:/var/azuracast/stations
- shoutcast2_install:/var/azuracast/servers/shoutcast2
init: true
restart: always
nginx:
image: azuracast/azuracast_nginx:latest
build:
context: ../docker-azuracast-nginx
ports:
- '${AZURACAST_HTTP_PORT:-80}:80'
- '${AZURACAST_HTTPS_PORT:-443}:443'
depends_on:
- web
- stations
volumes:
- .:/var/azuracast/www
- nginx_letsencrypt_certs:/etc/nginx/ssl
- nginx_letsencrypt_www:/var/www/letsencrypt
restart: always
# To use the LetsEncrypt support:
# docker-compose run --rm letsencrypt certonly --webroot -w /var/www/letsencrypt
letsencrypt:
image: certbot/certbot
command: /bin/true
volumes:
- nginx_letsencrypt_certs:/etc/letsencrypt
- nginx_letsencrypt_www:/var/www/letsencrypt
logging: &default-logging
options:
max-size: "1m"
max-file: "5"
mariadb:
image: azuracast/azuracast_db:latest
@ -58,6 +42,7 @@ services:
environment:
<< : *default-environment
restart: always
logging: *default-logging
influxdb:
image: azuracast/azuracast_influxdb:latest
@ -66,6 +51,7 @@ services:
volumes:
- influx_data:/var/lib/influxdb
restart: always
logging: *default-logging
redis:
image: azuracast/azuracast_redis:latest
@ -74,42 +60,7 @@ services:
ports:
- "127.0.0.1:6379:6379"
restart: always
cron:
container_name: azuracast_cron
image: azuracast/azuracast_web:latest
volumes_from:
- web
depends_on:
- mariadb
- influxdb
- stations
- redis
env_file: azuracast.env
environment:
<<: *default-environment
command: 'cron'
init: true
restart: always
cli:
build:
context: ./util/docker/testing
volumes_from:
- web
depends_on:
- mariadb
- influxdb
- stations
- redis
env_file: azuracast.env
environment:
<<: *default-environment
user: 'azuracast'
working_dir: '/var/azuracast/www'
command: '/bin/true'
tty: true # Pretty colors
init: true
logging: *default-logging
stations:
container_name: azuracast_stations
@ -134,10 +85,11 @@ services:
- '8046:8046'
volumes:
- station_data:/var/azuracast/stations
- nginx_letsencrypt_certs:/etc/nginx/ssl:ro
- letsencrypt:/etc/nginx/ssl:ro
- shoutcast2_install:/var/azuracast/servers/shoutcast2
init: true
restart: always
logging: *default-logging
# chronograf:
# image: chronograf:alpine
@ -161,8 +113,7 @@ services:
# BLACKFIRE_SERVER_TOKEN: ""
volumes:
nginx_letsencrypt_certs: {}
nginx_letsencrypt_www: {}
letsencrypt: {}
db_data: {}
influx_data: {}
station_data: {}

View File

@ -5,7 +5,7 @@ services:
volumes:
- ./migration/influxdb:/tmp/migration
cli:
web:
volumes:
- ../stations:/tmp/migration

View File

@ -13,7 +13,12 @@ version: '2.2'
services:
web:
image: azuracast/azuracast_web:latest
image: azuracast/azuracast_web_v2:latest
# Want to customize the HTTP/S ports? Follow the instructions here:
# https://github.com/AzuraCast/AzuraCast/blob/master/SUPPORT.md#use-non-standard-ports
ports:
- '${AZURACAST_HTTP_PORT:-80}:80'
- '${AZURACAST_HTTPS_PORT:-443}:443'
depends_on:
- mariadb
- influxdb
@ -21,48 +26,19 @@ services:
- redis
env_file: azuracast.env
environment: &default-environment
AZURACAST_DC_REVISION: 4
AZURACAST_DC_REVISION: 5
volumes:
- letsencrypt:/etc/letsencrypt
- www_data:/var/azuracast/www
- tmp_data:/var/azuracast/www_tmp
- station_data:/var/azuracast/stations
- shoutcast2_install:/var/azuracast/servers/shoutcast2
init: true
restart: always
logging:
logging: &default-logging
options:
max-size: "1m"
max-file: "5"
nginx:
image: azuracast/azuracast_nginx:latest
# Want to customize the HTTP/S ports? Follow the instructions here:
# https://github.com/AzuraCast/AzuraCast/blob/master/SUPPORT.md#use-non-standard-ports
ports:
- '${AZURACAST_HTTP_PORT:-80}:80'
- '${AZURACAST_HTTPS_PORT:-443}:443'
depends_on:
- web
- stations
volumes:
- www_data:/var/azuracast/www
- nginx_letsencrypt_certs:/etc/nginx/ssl
- nginx_letsencrypt_www:/var/www/letsencrypt
restart: always
logging:
options:
max-size: "1m"
max-file: "5"
# To use the LetsEncrypt support:
# docker-compose run --rm letsencrypt certonly --webroot -w /var/www/letsencrypt
letsencrypt:
image: certbot/certbot
command: /bin/true
volumes:
- nginx_letsencrypt_certs:/etc/letsencrypt
- nginx_letsencrypt_www:/var/www/letsencrypt
mariadb:
image: azuracast/azuracast_db:latest
volumes:
@ -71,55 +47,19 @@ services:
environment:
<<: *default-environment
restart: always
logging: *default-logging
influxdb:
image: azuracast/azuracast_influxdb:latest
volumes:
- influx_data:/var/lib/influxdb
restart: always
logging: *default-logging
redis:
image: azuracast/azuracast_redis:latest
restart: always
cron:
container_name: azuracast_cron
image: azuracast/azuracast_web:latest
volumes_from:
- web
depends_on:
- mariadb
- influxdb
- stations
- redis
env_file: azuracast.env
environment:
<<: *default-environment
command: 'cron'
init: true
restart: always
logging:
options:
max-size: "1m"
max-file: "3"
cli:
image: azuracast/azuracast_web:latest
volumes_from:
- web
depends_on:
- mariadb
- influxdb
- stations
- redis
env_file: azuracast.env
environment:
<<: *default-environment
user: 'azuracast'
working_dir: '/var/azuracast/www'
command: '/bin/true'
tty: true # Pretty colors
init: true
logging: *default-logging
stations:
container_name: azuracast_stations
@ -158,20 +98,16 @@ services:
volumes:
- station_data:/var/azuracast/stations
- shoutcast2_install:/var/azuracast/servers/shoutcast2
- nginx_letsencrypt_certs:/etc/nginx/ssl:ro
- letsencrypt:/etc/letsencrypt:ro
init: true
restart: always
logging:
options:
max-size: "1m"
max-file: "5"
logging: *default-logging
volumes:
nginx_letsencrypt_certs: {}
nginx_letsencrypt_www: {}
db_data: {}
influx_data: {}
station_data: {}
letsencrypt: {}
shoutcast2_install: {}
www_data: {}
station_data: {}
tmp_data: {}
www_data: {}

View File

@ -2,16 +2,10 @@ version: '2.2'
services:
web:
volumes:
- .:/var/azuracast/www
cli:
image: azuracast_cli:latest
build:
context: ./util/docker/testing
environment:
APPLICATION_ENV: "testing"
nginx:
volumes:
- .:/var/azuracast/www

View File

@ -62,8 +62,8 @@ sleep 15
# Run Docker AzuraCast-specific installer
docker-compose -f docker-compose.yml -f docker-compose.migrate.yml run --rm influxdb import_folder /tmp/migration/
docker-compose -f docker-compose.yml -f docker-compose.migrate.yml exec mariadb import_file /tmp/database.sql
docker-compose -f docker-compose.yml -f docker-compose.migrate.yml run --rm cli azuracast_migrate_stations /tmp/migration
docker-compose -f docker-compose.yml -f docker-compose.migrate.yml run --rm cli azuracast_install
docker-compose -f docker-compose.yml -f docker-compose.migrate.yml run --user="azuracast" --rm web azuracast_migrate_stations /tmp/migration
docker-compose -f docker-compose.yml -f docker-compose.migrate.yml run --user="azuracast" --rm web azuracast_install
docker-compose -f docker-compose.yml -f docker-compose.migrate.yml down
docker-compose up -d

View File

@ -89,7 +89,7 @@ install() {
fi
docker-compose pull
docker-compose run --rm cli azuracast_install
docker-compose run --user="azuracast" --rm web azuracast_install
docker-compose up -d
}
@ -122,7 +122,7 @@ update() {
docker volume rm azuracast_tmp_data
docker-compose pull
docker-compose run --rm cli azuracast_update
docker-compose run --user="azuracast" --rm web azuracast_update
docker-compose up -d
docker rmi $(docker images | grep "none" | awk '/ / { print $3 }') 2> /dev/null
@ -236,21 +236,10 @@ uninstall() {
#
# Create and link a LetsEncrypt SSL certificate.
# Usage: ./docker.sh letsencrypt-create
# Usage: ./docker.sh letsencrypt-create domainname.example.com
#
letsencrypt-create() {
docker-compose run --rm letsencrypt certonly --webroot -w /var/www/letsencrypt $*
echo "-------------------------------------------------------------------------------"
echo "Re-enter the domain name that was entered in the previous step: "
read reply </dev/tty
docker-compose run --rm nginx letsencrypt_connect $reply
echo "Reloading nginx..."
docker-compose kill -s SIGHUP nginx
echo "Nginx reloaded; letsencrypt certificate has been set up."
docker-compose run --user="azuracast" --rm web letsencrypt_connect $*
}
#
@ -258,7 +247,7 @@ letsencrypt-create() {
# Usage: ./docker.sh letsencrypt-renew
#
letsencrypt-renew() {
docker-compose run --rm letsencrypt renew --webroot -w /var/www/letsencrypt $*
docker-compose run --user="azuracast" --rm web letsencrypt_renew $*
}
$*

View File

@ -3,6 +3,7 @@ namespace App\Console\Command;
use App\MessageQueue;
use Azura\Console\Command\CommandAbstract;
use Monolog\Logger;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@ -29,9 +30,15 @@ class ProcessMessageQueue extends CommandAbstract
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var Logger $logger */
$logger = $this->get(Logger::class);
$runtime = (int)$input->getArgument('runtime');
if ($runtime < 1) {
$runtime = \PHP_INT_MAX;
$logger->info('Running message queue processor with indefinite length.');
} else {
$logger->info(sprintf('Running message queue processor for %d seconds.', $runtime));
}
/** @var MessageQueue $message_queue */

View File

@ -35,27 +35,19 @@ class Sync extends CommandAbstract
switch ($input->getArgument('task')) {
case 'long':
$output->writeln('Running Long (1-hour) Sync...');
$sync->syncLong();
break;
case 'medium':
$output->writeln('Running Medium (5-minutes) Sync...');
$sync->syncMedium();
break;
case 'short':
$output->writeln('Running Short (1-minute) Sync...');
$sync->syncShort();
break;
case 'nowplaying':
default:
$output->writeln('Running Now-Playing (15-second) Sync...');
define('NOWPLAYING_SEGMENT', 1);
$sync->syncNowplaying();
break;

View File

@ -69,7 +69,7 @@ class Manager implements EventSubscriberInterface
$compose_revision = $_ENV['AZURACAST_DC_REVISION'] ?? 1;
if ($compose_revision < 4) {
if ($compose_revision < 5) {
$event->addNotification(new Notification(
__('Your <code>docker-compose.yml</code> file is out of date!'),
__('You should update your <code>docker-compose.yml</code> file to reflect the newest changes. View the <a href="%s" target="_blank">latest version of the file</a> and update your file accordingly.<br>You can also use the <code>./docker.sh</code> utility script to automatically update your file.', 'https://raw.githubusercontent.com/AzuraCast/AzuraCast/master/docker-compose.sample.yml'),

View File

@ -480,7 +480,8 @@ class Liquidsoap extends AbstractBackend implements EventSubscriberInterface
$params = (array)$params;
$params['api_auth'] = $station->getAdapterApiKey();
$api_url = 'http://nginx/api/internal/'.$station->getId().'/'.$endpoint;
$service_uri = (APP_DOCKER_REVISION >= 5) ? 'web' : 'nginx';
$api_url = 'http://'.$service_uri.'/api/internal/'.$station->getId().'/'.$endpoint;
$curl_request = 'curl -s --request POST --url '.$api_url;
foreach($params as $param_key => $param_val) {
$curl_request .= ' --form '.$param_key.'='.$param_val;

View File

@ -79,7 +79,12 @@ abstract class AbstractFrontend extends \App\Radio\AbstractAdapter
*/
protected function _getStationWatcherCommand(Entity\Station $station, $adapter, $watch_uri): string
{
$base_url = (APP_INSIDE_DOCKER) ? 'http://nginx' : 'http://localhost';
if (APP_INSIDE_DOCKER) {
$base_url = (APP_DOCKER_REVISION >= 5) ? 'http://web' : 'http://nginx';
} else {
$base_url = 'http://localhost';
}
$notify_uri = $base_url.'/api/internal/'.$station->getId().'/notify?api_auth='.$station->getAdapterApiKey();
return '/var/azuracast/servers/station-watcher/station-watcher '.$adapter.' '.$watch_uri.' '.$notify_uri.' '.$station->getShortName();

View File

@ -67,6 +67,7 @@ class Runner
*/
public function syncNowplaying($force = false)
{
$this->logger->info('Running Now Playing sync task');
$this->_initSync(10);
// Prevent nowplaying from running on top of itself.
@ -97,6 +98,7 @@ class Runner
*/
public function syncShort($force = false)
{
$this->logger->info('Running 1-minute sync task');
$this->_initSync(60);
foreach($this->tasks_short as $task) {
@ -117,6 +119,7 @@ class Runner
*/
public function syncMedium($force = false)
{
$this->logger->info('Running 5-minute sync task');
$this->_initSync(300);
foreach($this->tasks_medium as $task) {
@ -137,6 +140,7 @@ class Runner
*/
public function syncLong($force = false)
{
$this->logger->info('Running 1-hour sync task');
$this->_initSync(1800);
foreach($this->tasks_long as $task) {

View File

@ -1,4 +1,4 @@
FROM azuracast/azuracast_web:latest
FROM azuracast/azuracast_web:v2
ENV PATH="${PATH}:/var/azuracast/.composer/vendor/bin"