Commit bee4fa22 authored by David Trattnig's avatar David Trattnig
Browse files

Initial Docker integration.

parent 11dbd6b0
FROM python:3.6.9-stretch
FROM python:3.7.7-buster
MAINTAINER Gottfried Gaisbauer <gottfried.gaisbauer@servus.at>
MAINTAINER David Trattnig <david.trattnigr@subsquare.at>
RUN set -ex \
&& rm -f /usr/bin/python && ln -s /usr/local/bin/python /usr/bin/python \
......@@ -8,10 +8,13 @@ RUN set -ex \
RUN set -ex \
&& apt-get update -q \
&& apt-get install -y -q --no-install-recommends libev4 libev-dev \
liquidsoap liquidsoap-plugin-alsa liquidsoap-plugin-icecast liquidsoap-plugin-jack liquidsoap-plugin-pulseaudio \
liquidsoap-plugin-flac liquidsoap-plugin-lame liquidsoap-plugin-mad liquidsoap-plugin-ogg liquidsoap-plugin-opus liquidsoap-plugin-faad \
liquidsoap-plugin-taglib \
&& apt-get install -y -q --no-install-recommends \
supervisor \
gunicorn \
redis-server \
libsndfile1 \
ffmpeg \
quelcom \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY requirements.txt /tmp/requirements.txt
......@@ -19,5 +22,5 @@ COPY requirements.txt /tmp/requirements.txt
RUN pip3 install -r /tmp/requirements.txt
RUN set -ex \
&& adduser --home /srv --no-create-home --system --uid 1000 --group app \
&& adduser app audio
&& adduser --home /srv --no-create-home --system --uid 1000 --group engineuser \
&& adduser engineuser audio
#!/bin/bash
mode="engine"
docker="false"
if [[ $* =~ ^(engine|core|lqs|api-dev|api)$ ]]; then
mode=$1
fi
if [[ $* =~ ^(docker)$ ]]; then
docker="true"
fi
echo "[ Run mode=$mode ]"
echo "[ Docker=$docker ]"
### Runs Engine Core & Liquidsoap ###
# +++ DEFAULT COMMANDS +++ #
if [[ $mode == "engine" ]]; then
/usr/bin/env python3.7 engine-core.py
fi
if [[ $docker == "false" ]]; then
### Runs Engine Core only ###
### Runs Engine Core & Liquidsoap ###
if [[ $mode == "core" ]]; then
/usr/bin/env python3.7 engine-core.py --without-lqs
fi
if [[ $mode == "engine" ]]; then
/usr/bin/env python3.7 engine-core.py
fi
### Runs Liquidsoap only ###
### Runs Engine Core only ###
if [[ $mode == "lqs" ]]; then
lqs=$(/usr/bin/env python3.7 engine-core.py --get-lqs-command)
eval "$lqs"
fi
if [[ $mode == "core" ]]; then
/usr/bin/env python3.7 engine-core.py --without-lqs
fi
### Runs Liquidsoap only ###
if [[ $mode == "lqs" ]]; then
lqs=$(/usr/bin/env python3.7 engine-core.py --get-lqs-command)
eval "$lqs"
fi
### Runs the API Server (Development) ###
if [[ $mode == "api-dev" ]]; then
echo "Building Web Applications"
sh ./script/build-web.sh
echo "Starting API Server"
/usr/bin/env python3.7 engine-api.py
fi
### Runs the API Server (Production) ###
### Runs the API Server (Development) ###
if [[ $mode == "api" ]]; then
echo "Building Web Applications"
sh ./script/build-web.sh
echo "Activating Python Environment"
source ../python-env/bin/activate
echo "Starting API Server"
gunicorn -c configuration/gunicorn.conf.py engine-api:app
fi
if [[ $mode == "api-dev" ]]; then
echo "Building Web Applications"
sh ./script/build-web.sh
echo "Starting API Server"
/usr/bin/env python3.7 engine-api.py
fi
### Runs the API Server (Production) ###
if [[ $mode == "api" ]]; then
echo "Building Web Applications"
sh ./script/build-web.sh
echo "Activating Python Environment"
source ../python-env/bin/activate
echo "Starting API Server"
gunicorn -c configuration/gunicorn.conf.py engine-api:app
# +++ DOCKER COMMANDS +++ #
if [[ $docker == "true" ]]; then
BASE_D=$(realpath "${BASH_SOURCE%/*}/")
### Runs Engine Core & Liquidsoap ###
if [[ $mode == "engine" ]]; then
exec sudo docker run --name aura-engine --rm -it \
-u $UID:$GID \
-p 127.0.0.1:8050:5000 \
-v "$BASE_D":/srv \
-v "$BASE_D/configuration/":/etc/aura \
--tmpfs /var/log/aura/ aura/engine /srv/engine-core.py
fi
### Runs Engine Core only ###
if [[ $mode == "core" ]]; then
exec sudo docker run --name aura-engine-core --rm -it \
-u $UID:$GID \
-p 127.0.0.1:8050:5000 \
-v "$BASE_D":/srv \
-v "$BASE_D/configuration/":/etc/aura \
--tmpfs /var/log/aura/ aura/engine /srv/engine-core.py "--without-lqs"
fi
### Runs Liquidsoap only ###
if [[ $mode == "lqs" ]]; then
lqs=$(/usr/bin/env python3.7 engine-core.py --get-lqs-command)
eval "$lqs"
exec sudo docker run --name aura-engine-liquidsoap --rm -it \
-u 1000:1000 \
-v "$BASE_D":/srv \
-v "$BASE_D/configuration/":/etc/aura \
--tmpfs /var/log/aura/ \
--device /dev/snd aura/engine /bin/bash \
-c "cd /srv/modules/liquidsoap && liquidsoap --debug --verbose engine.liq"
fi
### Runs Engine API using Gunicorn ###
if [[ $mode == "engine" ]]; then
exec sudo docker run --name aura-engine-api --rm -it \
-u $UID:$GID \
-p 127.0.0.1:8050:5000 \
-v "$BASE_D":/srv \
-v "$BASE_D/configuration/":/etc/aura \
--tmpfs /var/log/aura/ aura/engine /srv/engine-api.py \
--device aura/engine /bin/bash \
-c "gunicorn -c configuration/gunicorn.conf.py engine-api:app"
fi
fi
\ No newline at end of file
#!/bin/bash
BASE_D=$(realpath "${BASH_SOURCE%/*}/")
exec sudo docker run --name aura-engine --rm -it -u $UID:$GID -p 127.0.0.1:8050:5000 -v "$BASE_D":/srv -v "$BASE_D/configuration/":/etc/aura --tmpfs /var/log/aura/ aura/engine /srv/aura.py
#!/bin/bash
BASE_D=$(realpath "${BASH_SOURCE%/*}/")
exec sudo docker run --name aura-engine-liquidsoap --rm -it -u 1000:1000 -v "$BASE_D":/srv -v "$BASE_D/configuration/":/etc/aura --tmpfs /var/log/aura/ --device /dev/snd aura/engine /bin/bash -c "cd /srv/modules/liquidsoap && liquidsoap --debug --verbose engine.liq"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment