Make Pandora SPOC-compatible
This commit is contained in:
parent
3e8032d867
commit
b79323b4b7
@ -6,3 +6,4 @@ rm -rf "${VOLUMES_DIR}/opendatakit"
|
||||
|
||||
# Unregister application
|
||||
vmmgr unregister-app opendatakit
|
||||
vmmgr unregister-app opendatakit-build
|
||||
|
34
lxc-apps/pandora/app
Normal file
34
lxc-apps/pandora/app
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"version": "0.0.1-200313",
|
||||
"meta": {
|
||||
"title": "Pan.do/ra",
|
||||
"desc-cs": "Archiv medií",
|
||||
"desc-en": "Media archive",
|
||||
"license": "GPL"
|
||||
},
|
||||
"containers": {
|
||||
"pandora": {
|
||||
"image": "pandora_0.0.1-200313",
|
||||
"depends": [
|
||||
"pandora-postgres",
|
||||
"pandora-rabbitmq"
|
||||
],
|
||||
"mounts": {
|
||||
"pandora/pandora_conf": "srv/pandora/conf",
|
||||
"pandora/pandora_data": "srv/pandora/data"
|
||||
}
|
||||
},
|
||||
"pandora-postgres": {
|
||||
"image": "postgres_12.2.0-200313",
|
||||
"mounts": {
|
||||
"pandora/postgres_data": "var/lib/postgresql"
|
||||
}
|
||||
},
|
||||
"pandora-rabbitmq": {
|
||||
"image": "rabbitmq_3.7.18-200313",
|
||||
"mounts": {
|
||||
"pandora/rabbitmq_data": "var/lib/rabbitmq/mnesia"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +1,23 @@
|
||||
IMAGE pandora_0.0.1-190620
|
||||
FROM alpine3.9-python3.6_3.6.8-190620
|
||||
IMAGE pandora_0.0.1-200313
|
||||
FROM alpine3.11-python3.8_3.8.2-200313
|
||||
|
||||
RUN EOF
|
||||
# Install runtime dependencies
|
||||
apk --no-cache add ffmpeg imagemagick imlib2 libogg libtheora libvpx mkvtoolnix nginx poppler-utils py3-geoip py3-lxml py3-numpy py3-pillow py3-psycopg2
|
||||
apk --no-cache add ffmpeg imagemagick imlib2 libogg libtheora libvpx mkvtoolnix nginx poppler-utils py3-lxml py3-numpy py3-pillow py3-psycopg2
|
||||
pip3 install pyinotify
|
||||
|
||||
# Install build dependencies
|
||||
apk --no-cache add --virtual .deps autoconf automake build-base flac-dev git imlib2-dev libogg-dev libtheora-dev libtool libvpx-dev libvorbis-dev python3-dev
|
||||
|
||||
# Compile liboggz
|
||||
wget https://ftp.osuosl.org/pub/xiph/releases/liboggz/liboggz-1.1.1.tar.gz -O /tmp/liboggz.tgz
|
||||
tar xf /tmp/liboggz.tgz -C /tmp
|
||||
wget https://ftp.osuosl.org/pub/xiph/releases/liboggz/liboggz-1.1.1.tar.gz -O - | tar xzf - -C /tmp
|
||||
cd /tmp/liboggz-1.1.1
|
||||
./configure
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
make install
|
||||
|
||||
# Compile libfishsound
|
||||
wget https://ftp.osuosl.org/pub/xiph/releases/libfishsound/libfishsound-1.0.0.tar.gz -O /tmp/libfishsound.tgz
|
||||
tar xf /tmp/libfishsound.tgz -C /tmp/
|
||||
wget https://ftp.osuosl.org/pub/xiph/releases/libfishsound/libfishsound-1.0.0.tar.gz -O - | tar xzf - -C /tmp
|
||||
cd /tmp/libfishsound-1.0.0
|
||||
./configure
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
@ -34,17 +32,17 @@ RUN EOF
|
||||
make install
|
||||
|
||||
# Compile Oxframe
|
||||
git clone --depth 1 https://code.0x2620.org/0x2620/oxframe /tmp/oxframe
|
||||
git clone --depth 1 https://code.0x2620.org/0x2620/oxframe.git /tmp/oxframe
|
||||
cd /tmp/oxframe
|
||||
sed -i '/man\/oxframe/d' Makefile
|
||||
make
|
||||
make install
|
||||
|
||||
# Clone Pandora git repositories
|
||||
git clone --depth 1 https://git.0x2620.org/pandora.git /srv/pandora
|
||||
git clone --depth 1 https://git.0x2620.org/oxjs.git /srv/pandora/static/oxjs
|
||||
git clone --depth 1 https://git.0x2620.org/python-ox.git /srv/pandora/src/python-ox
|
||||
git clone --depth 1 https://git.0x2620.org/oxtimelines.git /srv/pandora/src/oxtimelines
|
||||
git clone --depth 1 https://code.0x2620.org/0x2620/pandora.git /srv/pandora
|
||||
git clone --depth 1 https://code.0x2620.org/0x2620/oxjs.git /srv/pandora/static/oxjs
|
||||
git clone --depth 1 https://code.0x2620.org/0x2620/python-ox.git /srv/pandora/src/python-ox
|
||||
git clone --depth 1 https://code.0x2620.org/0x2620/oxtimelines.git /srv/pandora/src/oxtimelines
|
||||
pip3 install -e /srv/pandora/src/python-ox
|
||||
pip3 install -e /srv/pandora/src/oxtimelines
|
||||
pip3 install -r /srv/pandora/requirements.txt
|
||||
@ -61,7 +59,7 @@ RUN EOF
|
||||
adduser -S -u 8080 -h /srv/pandora -s /bin/false -g pandora -G pandora pandora
|
||||
EOF
|
||||
|
||||
COPY lxc
|
||||
COPY image.d
|
||||
|
||||
RUN EOF
|
||||
# Update static files for Czech translation
|
@ -1,59 +1,58 @@
|
||||
#!/bin/sh
|
||||
set -ev
|
||||
|
||||
# Volumes
|
||||
POSTGRES_DATA="${VOLUMES_DIR}/pandora/postgres_data"
|
||||
RABBITMQ_DATA="${VOLUMES_DIR}/pandora/rabbitmq_data"
|
||||
PANDORA_CONF="${VOLUMES_DIR}/pandora/pandora_conf"
|
||||
PANDORA_DATA="${VOLUMES_DIR}/pandora/pandora_data"
|
||||
|
||||
# Create Postgres instance
|
||||
mkdir -p /srv/pandora/postgres_data
|
||||
chown -R 105432:105432 /srv/pandora/postgres_data
|
||||
chmod 700 /srv/pandora/postgres_data
|
||||
lxc-execute -n pandora-postgres -- initdb -D /var/lib/postgresql
|
||||
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
|
||||
spoc-container exec pandora-postgres -- initdb -D /var/lib/postgresql
|
||||
|
||||
# Configure Postgres
|
||||
cp postgres_data/postgresql.conf /srv/pandora/postgres_data/postgresql.conf
|
||||
cp postgres_data/pg_hba.conf /srv/pandora/postgres_data/pg_hba.conf
|
||||
install -o 105432 -g 105432 -m 600 postgres_data/postgresql.conf ${POSTGRES_DATA}/postgresql.conf
|
||||
install -o 105432 -g 105432 -m 600 postgres_data/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf
|
||||
|
||||
# Create PostgreSQL user and database
|
||||
export PANDORA_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
||||
service lxc-pandora-postgres start
|
||||
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 pandora-postgres -- psql
|
||||
spoc-container start pandora-postgres
|
||||
envsubst <createdb.sql | spoc-container exec pandora-postgres -- psql
|
||||
|
||||
# Create RabbitMQ directory structure
|
||||
mkdir -p /srv/pandora/rabbitmq_data
|
||||
chown 105672:105672 /srv/pandora/rabbitmq_data
|
||||
install -o 105672 -g 105672 -m 750 -d ${RABBITMQ_DATA}
|
||||
|
||||
# Configure RabbitMQ
|
||||
# Configure RabbitMQ virtualhost
|
||||
export PANDORA_RABBIT_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
||||
service lxc-pandora-rabbitmq start
|
||||
lxc-attach pandora-rabbitmq -- rabbitmqctl add_user pandora ${PANDORA_RABBIT_PWD}
|
||||
lxc-attach pandora-rabbitmq -- rabbitmqctl add_vhost /pandora
|
||||
lxc-attach pandora-rabbitmq -- rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
|
||||
spoc-container start pandora-rabbitmq
|
||||
spoc-container exec pandora-rabbitmq -- rabbitmqctl add_user pandora ${PANDORA_RABBIT_PWD}
|
||||
spoc-container exec pandora-rabbitmq -- rabbitmqctl add_vhost /pandora
|
||||
spoc-container exec pandora-rabbitmq -- rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
|
||||
|
||||
# Configure Pandora
|
||||
mkdir -p /srv/pandora/pandora_conf /srv/pandora/pandora_data
|
||||
chown 108080:108080 /srv/pandora/pandora_data
|
||||
cp pandora_conf/config.jsonc /srv/pandora/pandora_conf/config.jsonc
|
||||
cp pandora_conf/gunicorn_config.py /srv/pandora/pandora_conf/gunicorn_config.py
|
||||
envsubst <pandora_conf/local_settings.py >/srv/pandora/pandora_conf/local_settings.py
|
||||
chown -R 108080:108080 /srv/pandora/pandora_conf
|
||||
install -o 108080 -g 108080 -m 750 -d ${PANDORA_CONF}
|
||||
install -o 108080 -g 108080 -m 750 -d ${PANDORA_DATA}
|
||||
install -o 108080 -g 108080 -m 640 pandora_conf/config.jsonc ${PANDORA_CONF}/config.jsonc
|
||||
install -o 108080 -g 108080 -m 640 pandora_conf/gunicorn_config.py ${PANDORA_CONF}/gunicorn_config.py
|
||||
envsubst <pandora_conf/local_settings.py | install -o 108080 -g 108080 -m 640 /dev/stdin ${PANDORA_CONF}/local_settings.py
|
||||
|
||||
# Populate database
|
||||
lxc-execute pandora -- /srv/pandora/pandora/manage.py migrate --noinput
|
||||
lxc-execute pandora -- /srv/pandora/pandora/manage.py sqlfindindex
|
||||
lxc-execute pandora -- /srv/pandora/pandora/manage.py sync_itemsort
|
||||
lxc-execute pandora -- /srv/pandora/pandora/manage.py sync_documentsort
|
||||
spoc-container exec pandora -- /srv/pandora/pandora/manage.py migrate --noinput
|
||||
spoc-container exec pandora -- /srv/pandora/pandora/manage.py sqlfindindex
|
||||
spoc-container exec pandora -- /srv/pandora/pandora/manage.py sync_itemsort
|
||||
spoc-container exec pandora -- /srv/pandora/pandora/manage.py sync_documentsort
|
||||
|
||||
# Create admin account
|
||||
export PANDORA_ADMIN_USER=admin
|
||||
export PANDORA_ADMIN_EMAIL=admin@example.com
|
||||
export PANDORA_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
||||
export PANDORA_ADMIN_HASH=$(lxc-execute pandora -- sh -c "cd /srv/pandora && DJANGO_SETTINGS_MODULE=pandora.settings python3 -c \"from django.contrib.auth.hashers import make_password; print(make_password('${PANDORA_ADMIN_PWD}'))\"")
|
||||
envsubst <adminpwd.sql | lxc-attach -u 5432 -g 5432 pandora-postgres -- psql pandora
|
||||
|
||||
# Install config update script
|
||||
cp update-conf.sh /srv/pandora/update-conf.sh
|
||||
export PANDORA_ADMIN_HASH=$(spoc-container exec pandora -- sh -c "cd /srv/pandora && DJANGO_SETTINGS_MODULE=pandora.settings python3 -c \"from django.contrib.auth.hashers import make_password; print(make_password('${PANDORA_ADMIN_PWD}'))\"")
|
||||
envsubst <adminpwd.sql | spoc-container exec pandora-postgres -- psql pandora
|
||||
|
||||
# Stop services required for setup
|
||||
service lxc-pandora-postgres stop
|
||||
service lxc-pandora-rabbitmq stop
|
||||
spoc-container stop pandora-postgres
|
||||
spoc-container stop pandora-rabbitmq
|
||||
|
||||
# Register application
|
||||
vmmgr register-app pandora pandora "${PANDORA_ADMIN_USER}" "${PANDORA_ADMIN_PWD}"
|
||||
|
@ -1,34 +0,0 @@
|
||||
{
|
||||
"version": "0.0.1-190620",
|
||||
"meta": {
|
||||
"title": "Pan.do/ra",
|
||||
"desc-cs": "Archiv medií",
|
||||
"desc-en": "Media archive",
|
||||
"license": "GPL"
|
||||
},
|
||||
"containers": {
|
||||
"pandora": {
|
||||
"image": "pandora_0.0.1-190620",
|
||||
"depends": [
|
||||
"pandora-postgres",
|
||||
"pandora-rabbitmq"
|
||||
],
|
||||
"mounts": [
|
||||
["DIR", "/srv/pandora/pandora_conf", "/srv/pandora/conf"],
|
||||
["DIR", "/srv/pandora/pandora_data", "/srv/pandora/data"]
|
||||
]
|
||||
},
|
||||
"pandora-postgres": {
|
||||
"image": "postgres_11.3.0-190620",
|
||||
"mounts": [
|
||||
["DIR", "/srv/pandora/postgres_data", "/var/lib/postgresql"]
|
||||
]
|
||||
},
|
||||
"pandora-rabbitmq": {
|
||||
"image": "rabbitmq_3.7.11-190620",
|
||||
"mounts": [
|
||||
["DIR", "/srv/pandora/rabbitmq_data", "/var/lib/rabbitmq/mnesia"]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
set -ev
|
||||
|
||||
# Remove persistent data
|
||||
rm -rf /srv/pandora
|
||||
rm -rf "${VOLUMES_DIR}/pandora"
|
||||
|
||||
# Unregister application
|
||||
vmmgr unregister-app pandora
|
||||
|
Loading…
Reference in New Issue
Block a user