Initial commit of unified Docker build and standalone image.

This commit is contained in:
Buster "Silver Eagle" Neece 2021-06-22 07:36:58 -05:00
parent 8a6625f19f
commit f9221fb335
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
64 changed files with 430 additions and 344 deletions

View File

@ -6,9 +6,9 @@
!bin
!config
!resources/locale/compiled
!util/docker/web
!util/docker
!util/openapi.php
!web
!templates
!plugins
!crowdin.yaml
!crowdin.yaml

View File

@ -1,17 +1,72 @@
# Base install step (done first for caching purposes).
FROM ubuntu:focal as base
FROM ubuntu:focal as build_base
ENV TZ="UTC"
# Run base build process
COPY ./util/docker/web/ /bd_build
COPY ./util/docker/base/ /bd_build_base
RUN chmod a+x /bd_build/*.sh \
&& /bd_build/prepare.sh \
&& /bd_build/add_user.sh \
&& /bd_build/setup.sh \
&& /bd_build/cleanup.sh \
&& rm -rf /bd_build
RUN chmod a+x /bd_build_base/*.sh \
&& /bd_build_base/prepare.sh \
&& /bd_build_base/add_user.sh \
&& /bd_build_base/setup.sh \
&& /bd_build_base/cleanup.sh \
&& rm -rf /bd_build_base
#
# Icecast build stage (for later copy)
#
FROM azuracast/icecast-kh-ac:2.4.0-kh15-ac1 AS build_icecast
#
# Liquidsoap build stage
#
FROM build_base AS build_liquidsoap
# Install build tools
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -q -y --no-install-recommends \
build-essential libssl-dev libcurl4-openssl-dev bubblewrap unzip m4 software-properties-common \
ocaml opam \
autoconf automake
USER azuracast
RUN opam init --disable-sandboxing -a --bare && opam switch create ocaml-system.4.08.1
# Uncomment to Pin specific commit of Liquidsoap
RUN cd ~/ \
&& git clone --recursive https://github.com/savonet/liquidsoap.git \
&& cd liquidsoap \
&& git checkout 75d530c86bf638e3c50c08b7802d92270288e31b \
&& opam pin add --no-action liquidsoap .
ARG opam_packages="ladspa.0.1.5 ffmpeg.0.4.3 samplerate.0.1.4 taglib.0.3.3 mad.0.4.5 faad.0.4.0 fdkaac.0.3.1 lame.0.3.3 vorbis.0.7.1 cry.0.6.1 flac.0.1.5 opus.0.1.3 duppy.0.8.0 ssl liquidsoap"
RUN opam install -y ${opam_packages}
FROM build_base AS build_final
# Run base build process
COPY ./util/docker/final/ /bd_build_final
RUN chmod a+x /bd_build_final/*.sh \
&& /bd_build_final/setup.sh \
&& /bd_build_final/cleanup.sh \
&& rm -rf /bd_build_final
#
# Final unified container build
#
FROM build_final
# Import Icecast-KH from build container
COPY --from=build_icecast /usr/local/bin/icecast /usr/local/bin/icecast
COPY --from=build_icecast /usr/local/share/icecast /usr/local/share/icecast
# Import Liquidsoap from build container
COPY --from=build_liquidsoap --chown=azuracast:azuracast /var/azuracast/.opam/ocaml-system.4.08.1 /var/azuracast/.opam/ocaml-system.4.08.1
RUN ln -s /var/azuracast/.opam/ocaml-system.4.08.1/bin/liquidsoap /usr/local/bin/liquidsoap
#
# START Operations as `azuracast` user
@ -32,14 +87,17 @@ COPY --chown=azuracast:azuracast . .
RUN composer dump-autoload --optimize --classmap-authoritative \
&& touch /var/azuracast/.docker
VOLUME ["/var/azuracast/www_tmp", "/var/azuracast/backups", "/var/azuracast/sftpgo/persist"]
# Include radio services in PATH
ENV PATH="${PATH}:/var/azuracast/servers/shoutcast2"
VOLUME ["/var/azuracast/www_tmp", "/var/azuracast/backups", "/var/azuracast/sftpgo/persist", "/var/azuracast/servers/shoutcast2"]
#
# END Operations as `azuracast` user
#
USER root
EXPOSE 80 2022
EXPOSE 80 2022 9001 8000-8999
# Nginx Proxy environment variables.
ENV VIRTUAL_HOST="azuracast.local" \
@ -48,7 +106,7 @@ ENV VIRTUAL_HOST="azuracast.local" \
# Sensible default environment variables.
ENV LANG="en_US.UTF-8" \
APPLICATION_ENV="production" \
ENABLE_ADVANCED_FEATURES="false" \
AZURACAST_DOCKER_STANDALONE_MODE=0 \
MYSQL_HOST="mariadb" \
MYSQL_PORT=3306 \
MYSQL_USER="azuracast" \

View File

@ -61,6 +61,11 @@ return function (Application $console) {
)->setDescription(__('Convert translated locale files into PHP arrays.'));
// Setup
$console->command(
'azuracast:setup:initialize',
Command\InitializeCommand::class
)->setDescription(__('Ensure key settings are initialized within AzuraCast.'));
$console->command(
'azuracast:config:migrate',
Command\MigrateConfigCommand::class

View File

@ -27,9 +27,3 @@ services:
context: ../docker-azuracast-redis
ports:
- "127.0.0.1:6379:6379"
stations:
build:
context: ../docker-azuracast-radio
volumes:
- ./util/local_ssl:/etc/nginx/certs

View File

@ -14,7 +14,7 @@ version : '2.2'
services :
nginx_proxy :
container_name : nginx_proxy
image : "azuracast/azuracast_nginx_proxy:${AZURACAST_VERSION:-latest}"
image : "ghcr.io/azuracast/nginx_proxy:${AZURACAST_VERSION:-latest}"
ports :
- '${AZURACAST_HTTP_PORT:-80}:80'
- '${AZURACAST_HTTPS_PORT:-443}:443'
@ -34,7 +34,7 @@ services :
nginx_proxy_letsencrypt :
container_name : nginx_proxy_letsencrypt
image : "azuracast/azuracast_nginx_proxy_letsencrypt:${AZURACAST_VERSION:-latest}"
image : "ghcr.io/azuracast/nginx_proxy_letsencrypt:${AZURACAST_VERSION:-latest}"
volumes_from :
- nginx_proxy
volumes :
@ -48,19 +48,19 @@ services :
web :
container_name : azuracast_web
image : "azuracast/azuracast_web_v2:${AZURACAST_VERSION:-latest}"
image : "ghcr.io/azuracast/web:${AZURACAST_VERSION:-latest}"
# Want to customize the HTTP/S ports? Follow the instructions here:
# https://docs.azuracast.com/en/administration/docker#using-non-standard-ports
ports :
- '${AZURACAST_SFTP_PORT:-2022}:2022'
depends_on :
- mariadb
- stations
- redis
env_file : azuracast.env
environment :
LANG : ${LANG:-en_US.UTF-8}
AZURACAST_DC_REVISION : 11
AZURACAST_DC_REVISION : 12
AZURACAST_DOCKER_STANDALONE_MODE : 1
AZURACAST_VERSION : ${AZURACAST_VERSION:-latest}
AZURACAST_SFTP_PORT : ${AZURACAST_SFTP_PORT:-2022}
VIRTUAL_HOST : ${LETSENCRYPT_HOST:-azuracast.local}
@ -91,7 +91,7 @@ services :
mariadb :
container_name : azuracast_mariadb
image : "azuracast/azuracast_db:${AZURACAST_VERSION:-latest}"
image : "ghcr.io/azuracast/db:${AZURACAST_VERSION:-latest}"
volumes :
- db_data:/var/lib/mysql
env_file : azuracast.env
@ -102,7 +102,7 @@ services :
redis :
container_name : azuracast_redis
image : "azuracast/azuracast_redis:${AZURACAST_VERSION:-latest}"
image : "ghcr.io/azuracast/redis:${AZURACAST_VERSION:-latest}"
sysctls :
net.core.somaxconn : 1024
volumes :
@ -112,174 +112,6 @@ services :
restart : always
logging : *default-logging
stations :
container_name : azuracast_stations
image : "azuracast/azuracast_radio:${AZURACAST_VERSION:-latest}"
ports :
# This default mapping is the outgoing and incoming ports for the first 50 stations.
# You can override this port mapping in your own docker-compose.override.yml file.
# For instructions, see:
# https://docs.azuracast.com/en/administration/docker#expanding-the-station-port-range
- '8000:8000'
- '8005:8005'
- '8006:8006'
- '8010:8010'
- '8015:8015'
- '8016:8016'
- '8020:8020'
- '8025:8025'
- '8026:8026'
- '8030:8030'
- '8035:8035'
- '8036:8036'
- '8040:8040'
- '8045:8045'
- '8046:8046'
- '8050:8050'
- '8055:8055'
- '8056:8056'
- '8060:8060'
- '8065:8065'
- '8066:8066'
- '8070:8070'
- '8075:8075'
- '8076:8076'
- '8090:8090'
- '8095:8095'
- '8096:8096'
- '8100:8100'
- '8105:8105'
- '8106:8106'
- '8110:8110'
- '8115:8115'
- '8116:8116'
- '8120:8120'
- '8125:8125'
- '8126:8126'
- '8130:8130'
- '8135:8135'
- '8136:8136'
- '8140:8140'
- '8145:8145'
- '8146:8146'
- '8150:8150'
- '8155:8155'
- '8156:8156'
- '8160:8160'
- '8165:8165'
- '8166:8166'
- '8170:8170'
- '8175:8175'
- '8176:8176'
- '8180:8180'
- '8185:8185'
- '8186:8186'
- '8190:8190'
- '8195:8195'
- '8196:8196'
- '8200:8200'
- '8205:8205'
- '8206:8206'
- '8210:8210'
- '8215:8215'
- '8216:8216'
- '8220:8220'
- '8225:8225'
- '8226:8226'
- '8230:8230'
- '8235:8235'
- '8236:8236'
- '8240:8240'
- '8245:8245'
- '8246:8246'
- '8250:8250'
- '8255:8255'
- '8256:8256'
- '8260:8260'
- '8265:8265'
- '8266:8266'
- '8270:8270'
- '8275:8275'
- '8276:8276'
- '8280:8280'
- '8285:8285'
- '8286:8286'
- '8290:8290'
- '8295:8295'
- '8296:8296'
- '8300:8300'
- '8305:8305'
- '8306:8306'
- '8310:8310'
- '8315:8315'
- '8316:8316'
- '8320:8320'
- '8325:8325'
- '8326:8326'
- '8330:8330'
- '8335:8335'
- '8336:8336'
- '8340:8340'
- '8345:8345'
- '8346:8346'
- '8350:8350'
- '8355:8355'
- '8356:8356'
- '8360:8360'
- '8365:8365'
- '8366:8366'
- '8370:8370'
- '8375:8375'
- '8376:8376'
- '8380:8380'
- '8385:8385'
- '8386:8386'
- '8390:8390'
- '8395:8395'
- '8396:8396'
- '8400:8400'
- '8405:8405'
- '8406:8406'
- '8410:8410'
- '8415:8415'
- '8416:8416'
- '8420:8420'
- '8425:8425'
- '8426:8426'
- '8430:8430'
- '8435:8435'
- '8436:8436'
- '8440:8440'
- '8445:8445'
- '8446:8446'
- '8450:8450'
- '8455:8455'
- '8456:8456'
- '8460:8460'
- '8465:8465'
- '8466:8466'
- '8470:8470'
- '8475:8475'
- '8476:8476'
- '8480:8480'
- '8485:8485'
- '8486:8486'
- '8490:8490'
- '8495:8495'
- '8496:8496'
volumes :
- station_data:/var/azuracast/stations
- shoutcast2_install:/var/azuracast/servers/shoutcast2
- letsencrypt:/etc/nginx/certs
- tmp_data:/var/azuracast/www_tmp
networks :
- frontend
- backend
init : true
restart : always
ulimits : *default-ulimits
logging : *default-logging
networks :
frontend :
driver : bridge

View File

@ -111,6 +111,11 @@ __dotenv_cmd=.env
esac
}
# Shortcut to have Docker run YQ files
yq() {
docker run --rm -i -v "${PWD}":/workdir mikefarah/yq "$@"
}
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
@ -201,6 +206,19 @@ setup-release() {
.env --file .env set AZURACAST_VERSION=${AZURACAST_VERSION}
}
# Add Ports to Docker Compose
add-ports-to-docker-compose() {
local LEGACY_PORTS
LEGACY_PORTS="8000,8005,8006,8010,8015,8016,8020,8025,8026,8030,8035,8036,8040,8045,8046,8050,8055,8056,8060,8065,8066,8070,8075,8076,8090,8095,8096,8100,8105,8106,8110,8115,8116,8120,8125,8126,8130,8135,8136,8140,8145,8146,8150,8155,8156,8160,8165,8166,8170,8175,8176,8180,8185,8186,8190,8195,8196,8200,8205,8206,8210,8215,8216,8220,8225,8226,8230,8235,8236,8240,8245,8246,8250,8255,8256,8260,8265,8266,8270,8275,8276,8280,8285,8286,8290,8295,8296,8300,8305,8306,8310,8315,8316,8320,8325,8326,8330,8335,8336,8340,8345,8346,8350,8355,8356,8360,8365,8366,8370,8375,8376,8380,8385,8386,8390,8395,8396,8400,8405,8406,8410,8415,8416,8420,8425,8426,8430,8435,8436,8440,8445,8446,8450,8455,8456,8460,8465,8466,8470,8475,8476,8480,8485,8486,8490,8495,8496"
.env --file .env get AZURACAST_STATION_PORTS
local PORTS
PORTS="${REPLY:-$LEGACY_PORTS}"
yq eval ".services.web.ports += [$PORTS]" -i docker-compose.yml
}
#
# Run the initial installer of Docker and AzuraCast.
# Usage: ./docker.sh install
@ -285,6 +303,8 @@ install() {
else
curl -fsSL https://raw.githubusercontent.com/AzuraCast/AzuraCast/main/docker-compose.sample.yml -o docker-compose.yml
fi
add-ports-to-docker-compose
fi
if ask "Customize AzuraCast ports?" N; then
@ -384,6 +404,8 @@ update() {
cp docker-compose.yml docker-compose.backup.yml
mv docker-compose.new.yml docker-compose.yml
add-ports-to-docker-compose
else
rm docker-compose.new.yml

View File

@ -0,0 +1,79 @@
<?php
namespace App\Console\Command;
use App\Entity;
use App\Environment;
use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class InitializeCommand extends CommandAbstract
{
public function __invoke(
SymfonyStyle $io,
OutputInterface $output,
Environment $environment,
ContainerInterface $di,
Entity\Repository\SettingsRepository $settingsRepo,
Entity\Repository\StationRepository $stationRepo,
Entity\Repository\StorageLocationRepository $storageLocationRepo
): int {
$io->title(__('Initialize AzuraCast'));
$io->writeln(__('Initializing essential settings...'));
$io->listing(
[
__('Environment: %s', ucfirst($environment->getAppEnvironment())),
__('Installation Method: %s', $environment->isDocker() ? 'Docker' : 'Ansible'),
]
);
$io->newLine();
$io->section(__('Running Database Migrations'));
$this->runCommand(
$output,
'migrations:migrate',
[
'--allow-no-migration' => true,
]
);
$io->newLine();
$io->section(__('Generating Database Proxy Classes'));
$this->runCommand($output, 'orm:generate-proxies');
$io->newLine();
$io->section(__('Reload System Data'));
$this->runCommand($output, 'cache:clear');
$this->runCommand($output, 'queue:clear');
$stationRepo->clearNowPlaying();
// Clear settings that should be reset upon update.
$settings = $settingsRepo->readSettings();
$settings->setNowplaying(null);
$settings->updateUpdateLastRun();
$settings->setUpdateResults(null);
if ('127.0.0.1' !== $settings->getExternalIp()) {
$settings->setExternalIp(null);
}
$settingsRepo->writeSettings($settings);
$storageLocationRepo->createDefaultStorageLocations();
$io->newLine();
$io->success(
[
__('AzuraCast is now initialized.'),
]
);
return 0;
}
}

View File

@ -2,10 +2,8 @@
namespace App\Console\Command;
use App\Entity;
use App\Environment;
use App\Service\AzuraCastCentral;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
@ -17,9 +15,6 @@ class SetupCommand extends CommandAbstract
OutputInterface $output,
Environment $environment,
ContainerInterface $di,
Entity\Repository\SettingsRepository $settingsRepo,
Entity\Repository\StationRepository $stationRepo,
Entity\Repository\StorageLocationRepository $storageLocationRepo,
AzuraCastCentral $acCentral,
bool $update = false,
bool $loadFixtures = false
@ -27,36 +22,7 @@ class SetupCommand extends CommandAbstract
$io->title(__('AzuraCast Setup'));
$io->writeln(__('Welcome to AzuraCast. Please wait while some key dependencies of AzuraCast are set up...'));
$io->listing(
[
__('Environment: %s', ucfirst($environment->getAppEnvironment())),
__('Installation Method: %s', $environment->isDocker() ? 'Docker' : 'Ansible'),
]
);
if ($update) {
$io->note(__('Running in update mode.'));
}
$conn = $di->get(EntityManagerInterface::class)->getConnection();
$io->newLine();
$io->section(__('Running Database Migrations'));
$conn->ping();
$this->runCommand(
$output,
'migrations:migrate',
[
'--allow-no-migration' => true,
]
);
$io->newLine();
$io->section(__('Generating Database Proxy Classes'));
$conn->ping();
$this->runCommand($output, 'orm:generate-proxies');
$this->runCommand($output, 'azuracast:setup:initialize');
if ($loadFixtures || (!$environment->isProduction() && !$update)) {
$io->newLine();
@ -65,36 +31,11 @@ class SetupCommand extends CommandAbstract
$this->runCommand($output, 'azuracast:setup:fixtures');
}
$io->newLine();
$io->section(__('Reload System Data'));
$this->runCommand($output, 'cache:clear');
$this->runCommand($output, 'queue:clear');
$settings = $settingsRepo->readSettings();
$settings->setNowplaying(null);
$stationRepo->clearNowPlaying();
$io->newLine();
$io->section(__('Refreshing All Stations'));
$conn->ping();
$this->runCommand($output, 'azuracast:radio:restart');
// Clear settings that should be reset upon update.
$settings->updateUpdateLastRun();
$settings->setUpdateResults(null);
if ('127.0.0.1' !== $settings->getExternalIp()) {
$settings->setExternalIp(null);
}
$settingsRepo->writeSettings($settings);
$storageLocationRepo->createDefaultStorageLocations();
$io->newLine();
if ($update) {

View File

@ -19,7 +19,7 @@ class Version
public const RELEASE_CHANNEL_STABLE = 'stable';
// phpcs:disable Generic.Files.LineLength
public const LATEST_COMPOSE_REVISION = 11;
public const LATEST_COMPOSE_REVISION = 12;
public const LATEST_COMPOSE_URL = 'https://raw.githubusercontent.com/AzuraCast/AzuraCast/main/docker-compose.sample.yml';
public const UPDATE_URL = 'https://docs.azuracast.com/en/getting-started/updates';

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
source /bd_build_base/buildconfig
set -x
$minimal_apt_get_install sudo
@ -18,4 +18,4 @@ mkdir -p /var/azuracast/www /var/azuracast/backups /var/azuracast/www_tmp /var/a
chown -R azuracast:azuracast /var/azuracast
chmod -R 777 /var/azuracast/www_tmp
echo 'azuracast ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
echo 'azuracast ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

View File

@ -1,9 +1,9 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
source /bd_build_base/buildconfig
set -x
apt-get clean
rm -rf /var/lib/apt/lists/*
rm -rf /tmp/tmp*
rm -rf /tmp/tmp*

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
source /bd_build_base/buildconfig
set -x
## Prevent initramfs updates from trying to run grub and lilo.
@ -14,7 +14,7 @@ echo -n no > /etc/container_environment/INITRD
echo "UTC" > /etc/timezone
# Avoid ERROR: invoke-rc.d: policy-rc.d denied execution of start.
sed -i "s/^exit 101$/exit 0/" /usr/sbin/policy-rc.d
sed -i "s/^exit 101$/exit 0/" /usr/sbin/policy-rc.d
## Enable Ubuntu Universe, Multiverse, and deb-src for main.
sed -i 's/^#\s*\(deb.*main restricted\)$/\1/g' /etc/apt/sources.list
@ -67,4 +67,4 @@ chmod 700 /etc/container_environment
groupadd -g 8377 docker_env
chown :docker_env /etc/container_environment.sh /etc/container_environment.json
chmod 640 /etc/container_environment.sh /etc/container_environment.json
ln -s /etc/container_environment.sh /etc/profile.d/
ln -s /etc/container_environment.sh /etc/profile.d/

12
util/docker/base/setup.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
set -e
source /bd_build_base/buildconfig
set -x
# Install scripts commonly used during setup.
$minimal_apt_get_install runit curl wget tar zip unzip git rsync tzdata gpg-agent openssh-client
# Run service setup for all setup scripts
for f in /bd_build_base/setup/*.sh; do
bash "$f" -H
done

View File

@ -0,0 +1,15 @@
#!/bin/bash
set -e
source /bd_build_base/buildconfig
set -x
# Only install Icecast deps (Icecast is handled by another container).
$minimal_apt_get_install libxml2 libxslt1-dev libvorbis-dev openssl
mkdir -p /etc/nginx
chown azuracast:azuracast /etc/nginx
openssl req -new -nodes -x509 -subj "/C=US/ST=Texas/L=Austin/O=IT/CN=localhost" \
-days 365 -extensions v3_ca \
-keyout /etc/nginx/ssl.key \
-out /etc/nginx/ssl.crt

View File

@ -0,0 +1,10 @@
#!/bin/bash
set -e
source /bd_build_base/buildconfig
set -x
# Only install Liquidsoap deps (Liquidsoap build is handled by another container).
$minimal_apt_get_install libfaad-dev libfdk-aac-dev libflac-dev libmad0-dev libmp3lame-dev libogg-dev \
libopus-dev libpcre3-dev libtag1-dev libsamplerate0-dev libavcodec-dev libavfilter-dev \
libavformat-dev libavresample-dev libavutil-dev libpostproc-dev libswresample-dev \
ladspa-sdk multimedia-audio-plugins swh-plugins tap-plugins lsp-plugins-ladspa

View File

@ -0,0 +1,4 @@
export LC_ALL=C
export DEBIAN_FRONTEND=noninteractive
minimal_apt_get_install='apt-get install -y --no-install-recommends'

View File

@ -0,0 +1,9 @@
#!/bin/bash
set -e
source /bd_build_final/buildconfig
set -x
apt-get clean
rm -rf /var/lib/apt/lists/*
rm -rf /tmp/tmp*

View File

@ -2,9 +2,9 @@
if [ `whoami` != 'azuracast' ]; then
echo 'This script must be run as the "azuracast" user. Rerunning...'
sudo -E -u azuracast azuracast_cli "$@"
exit 1
setuser azuracast azuracast_cli "$@"
exit $?
fi
cd /var/azuracast/www
php bin/console "$@"
php bin/console "$@"

View File

@ -9,8 +9,8 @@ bool() {
if [ $(whoami) != 'azuracast' ]; then
echo 'This script must be run as the "azuracast" user. Rerunning...'
sudo -E -u azuracast azuracast_install "$@"
exit 1
setuser azuracast azuracast_install "$@"
exit $?
fi
echo "AzuraCast Setup"

View File

@ -9,8 +9,8 @@ bool() {
if [ $(whoami) != 'azuracast' ]; then
echo 'This script must be run as the "azuracast" user. Rerunning...'
sudo -E -u azuracast azuracast_install "$@"
exit 1
setuser azuracast azuracast_restore "$@"
exit $?
fi
echo "AzuraCast Setup"

View File

@ -2,4 +2,4 @@
source /etc/container_environment.sh
sudo -E -u azuracast "$@" >/proc/1/fd/1 2>/proc/1/fd/2
setuser azuracast "$@" >/proc/1/fd/1 2>/proc/1/fd/2

View File

@ -0,0 +1,64 @@
#!/usr/bin/python3
'''
Copyright (c) 2013-2015 Phusion Holding B.V.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''
import sys
import os
import pwd
def abort(message):
sys.stderr.write("setuser: %s\n" % message)
sys.exit(1)
def main():
'''
A simple alternative to sudo that executes a command as a user by setting
the user ID and user parameters to those described by the system and then
using execvp(3) to execute the command without the necessity of a TTY
'''
username = sys.argv[1]
try:
user = pwd.getpwnam(username)
except KeyError:
abort("user %s not found" % username)
os.initgroups(username, user.pw_gid)
os.setgid(user.pw_gid)
os.setuid(user.pw_uid)
os.environ['USER'] = username
os.environ['HOME'] = user.pw_dir
os.environ['UID'] = str(user.pw_uid)
try:
os.execvp(sys.argv[2], sys.argv[2:])
except OSError as e:
abort("cannot execute %s: %s" % (sys.argv[2], str(e)))
if __name__ == '__main__':
if len(sys.argv) < 3:
sys.stderr.write("Usage: /sbin/setuser USERNAME COMMAND [args..]\n")
sys.exit(1)
main()

View File

@ -1,6 +1,8 @@
#!/usr/bin/env bash
/usr/sbin/tmpreaper 12h --protect '.tmpreaper' --verbose \
/tmp \
/tmp/azuracast_nginx_client \
/tmp/azuracast_fastcgi_temp \
> /proc/1/fd/1 2> /proc/1/fd/2
/var/azuracast/stations/*/temp \
> /proc/1/fd/1 2> /proc/1/fd/2

View File

@ -0,0 +1,3 @@
#!/bin/sh
/usr/bin/supervisord -c /etc/supervisor/supervisord.conf

View File

@ -0,0 +1,22 @@
#!/bin/bash
set -e
source /bd_build_final/buildconfig
set -x
# Install common scripts
cp -rT /bd_build_final/scripts/ /usr/local/bin
chmod -R a+x /usr/local/bin
# Install runit scripts
cp -rT /bd_build_final/startup_scripts/. /etc/my_init.d/
cp -rT /bd_build_final/service/. /etc/service/
cp -rT /bd_build_final/service_standalone/. /etc/service_standalone/
chmod -R +x /etc/service
chmod -R +x /etc/service_standalone
chmod -R +x /etc/my_init.d
# Run service setup for all setup scripts
for f in /bd_build_final/setup/*.sh; do
bash "$f" -H
done

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
source /bd_build_final/buildconfig
set -x
add-apt-repository -y ppa:chris-needham/ppa

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
source /bd_build_final/buildconfig
set -x
$minimal_apt_get_install cron
@ -20,5 +20,5 @@ rm -f /etc/cron.daily/dpkg
rm -f /etc/cron.daily/password
rm -f /etc/cron.weekly/fstrim
cp -r /bd_build/cron/. /etc/cron.d/
chmod -R 600 /etc/cron.d/*
cp -r /bd_build_final/cron/. /etc/cron.d/
chmod -R 600 /etc/cron.d/*

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
source /bd_build_final/buildconfig
set -x
cd /tmp

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
source /bd_build_final/buildconfig
set -x
DOCKERIZE_VERSION=v0.6.1

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
source /bd_build_final/buildconfig
set -x
$minimal_apt_get_install flac

View File

@ -1,13 +1,13 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
source /bd_build_final/buildconfig
set -x
$minimal_apt_get_install nginx nginx-common nginx-extras openssl
# Install nginx and configuration
cp /bd_build/nginx/nginx.conf /etc/nginx/nginx.conf
cp /bd_build/nginx/azuracast.conf.tmpl /etc/nginx/azuracast.conf.tmpl
cp /bd_build_final/nginx/nginx.conf /etc/nginx/nginx.conf
cp /bd_build_final/nginx/azuracast.conf.tmpl /etc/nginx/azuracast.conf.tmpl
mkdir -p /etc/nginx/azuracast.conf.d/

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
source /bd_build_final/buildconfig
set -x
PHP_VERSION=8.0
@ -20,8 +20,8 @@ touch /run/php/php${PHP_VERSION}-fpm.pid
echo "PHP_VERSION=${PHP_VERSION}" >>/etc/php/.version
cp /bd_build/php/php.ini.tmpl /etc/php/${PHP_VERSION}/fpm/05-azuracast.ini.tmpl
cp /bd_build/php/www.conf.tmpl /etc/php/${PHP_VERSION}/fpm/www.conf.tmpl
cp /bd_build_final/php/php.ini.tmpl /etc/php/${PHP_VERSION}/fpm/05-azuracast.ini.tmpl
cp /bd_build_final/php/www.conf.tmpl /etc/php/${PHP_VERSION}/fpm/www.conf.tmpl
# Install Composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
@ -29,7 +29,7 @@ curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --fil
# Install PHP SPX profiler
$minimal_apt_get_install php${PHP_VERSION}-dev zlib1g-dev build-essential
cd /bd_build
cd /bd_build_final
git clone https://github.com/NoiseByNorthwest/php-spx.git
cd php-spx
phpize

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
source /bd_build_final/buildconfig
set -x
add-apt-repository -y ppa:sftpgo/sftpgo
@ -10,7 +10,7 @@ $minimal_apt_get_install sftpgo
mkdir -p /var/azuracast/sftpgo/persist /var/azuracast/sftpgo/backups
cp /bd_build/sftpgo/sftpgo.json /var/azuracast/sftpgo/sftpgo.json
cp /bd_build_final/sftpgo/sftpgo.json /var/azuracast/sftpgo/sftpgo.json
touch /var/azuracast/sftpgo/sftpgo.db
chown -R azuracast:azuracast /var/azuracast/sftpgo

View File

@ -0,0 +1,12 @@
#!/bin/bash
set -e
source /bd_build_final/buildconfig
set -x
# $minimal_apt_get_install python3-minimal python3-pip
# pip3 install setuptools supervisor
$minimal_apt_get_install supervisor
# mkdir -p /etc/supervisor
cp /bd_build_final/supervisor/supervisord.conf /etc/supervisor/supervisord.conf

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e
source /bd_build_final/buildconfig
set -x
$minimal_apt_get_install tmpreaper

View File

@ -1,6 +1,6 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
source /bd_build_final/buildconfig
set -x
$minimal_apt_get_install vorbis-tools

View File

@ -0,0 +1,18 @@
#!/bin/bash
bool() {
case "$1" in
Y* | y* | true | TRUE | 1) return 0 ;;
esac
return 1
}
STANDALONE_MODE=${AZURACAST_DOCKER_STANDALONE_MODE:-0}
if bool "$STANDALONE_MODE"; then
echo "Running in standalone mode; enabling optional services..."
cp /etc/service_standalone/. /etc/service/
else
echo "Not running in standalone mode; skipping optional services."
fi

View File

@ -0,0 +1,4 @@
#!/bin/bash
shopt -s dotglob
rm -rf /var/azuracast/www_tmp/*

View File

@ -0,0 +1,5 @@
#!/bin/bash
set -ex
azuracast_cli azuracast:setup:initialize

View File

@ -0,0 +1,25 @@
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
[inet_http_server] ; inet (TCP) server disabled by default
port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface)
[supervisord]
user=root
logfile=/var/azuracast/www_tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=true ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
[include]
files = /var/azuracast/stations/*/config/supervisord.conf conf.d/*

View File

@ -1,26 +0,0 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
set -x
# Install common scripts
cp -rT /bd_build/scripts/ /usr/local/bin
chmod -R a+x /usr/local/bin
# Install runit
$minimal_apt_get_install runit
# Install runit scripts
cp -rT /bd_build/startup_scripts/. /etc/my_init.d/
cp -rT /bd_build/runit/. /etc/service/
chmod -R +x /etc/service
chmod -R +x /etc/my_init.d
# Install scripts commonly used during setup.
$minimal_apt_get_install curl wget tar zip unzip git rsync tzdata gpg-agent openssh-client
# Run service setup for all setup scripts
for f in /bd_build/setup/*.sh; do
bash "$f" -H
done

View File

@ -1,6 +0,0 @@
#!/bin/bash
set -e
source /bd_build/buildconfig
set -x
$minimal_apt_get_install tmpreaper

View File

@ -1,24 +0,0 @@
#!/bin/bash
# Duplicate php-worker runit script based on environment variable
echo "Additional workers currently disabled."
exit 0
# Temporarily disabled. Explanation:
# The current worker setup uses MariaDB as the underlying message queue implementation. Multiple workers on the same
# queues causes multiple process to have write locks on the same table of the same database at the same time, which
# can tend to create a condition where the processes "pile up" on each other, causing semaphore lock overflow issues
# that can bring down an installation rather easily.
#
# Disabling this script forces a single worker to run to process message queues.
echo "Adding $ADDITIONAL_MEDIA_SYNC_WORKER_COUNT additional workers"
for ((WORKER_NUMBER = 1; WORKER_NUMBER <= ADDITIONAL_MEDIA_SYNC_WORKER_COUNT; WORKER_NUMBER++)); do
echo "Adding worker $WORKER_NUMBER..."
cp -r /etc/service/php-worker "/etc/service/php-worker-${WORKER_NUMBER}"
sed -i "s/app_worker_0/app_worker_${WORKER_NUMBER}/" "/etc/service/php-worker-${WORKER_NUMBER}/run"
done
echo "Done"