Make Pandora SPOC-compatible

This commit is contained in:
Disassembler 2020-03-22 13:44:46 +01:00
parent 3e8032d867
commit b79323b4b7
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
19 changed files with 78 additions and 80 deletions

View File

@ -6,3 +6,4 @@ rm -rf "${VOLUMES_DIR}/opendatakit"
# Unregister application # Unregister application
vmmgr unregister-app opendatakit vmmgr unregister-app opendatakit
vmmgr unregister-app opendatakit-build

34
lxc-apps/pandora/app Normal file
View 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"
}
}
}
}

View File

@ -1,25 +1,23 @@
IMAGE pandora_0.0.1-190620 IMAGE pandora_0.0.1-200313
FROM alpine3.9-python3.6_3.6.8-190620 FROM alpine3.11-python3.8_3.8.2-200313
RUN EOF RUN EOF
# Install runtime dependencies # 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 pip3 install pyinotify
# Install build dependencies # 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 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 # Compile liboggz
wget https://ftp.osuosl.org/pub/xiph/releases/liboggz/liboggz-1.1.1.tar.gz -O /tmp/liboggz.tgz wget https://ftp.osuosl.org/pub/xiph/releases/liboggz/liboggz-1.1.1.tar.gz -O - | tar xzf - -C /tmp
tar xf /tmp/liboggz.tgz -C /tmp
cd /tmp/liboggz-1.1.1 cd /tmp/liboggz-1.1.1
./configure ./configure
make -j $(getconf _NPROCESSORS_ONLN) make -j $(getconf _NPROCESSORS_ONLN)
make install make install
# Compile libfishsound # Compile libfishsound
wget https://ftp.osuosl.org/pub/xiph/releases/libfishsound/libfishsound-1.0.0.tar.gz -O /tmp/libfishsound.tgz wget https://ftp.osuosl.org/pub/xiph/releases/libfishsound/libfishsound-1.0.0.tar.gz -O - | tar xzf - -C /tmp
tar xf /tmp/libfishsound.tgz -C /tmp/
cd /tmp/libfishsound-1.0.0 cd /tmp/libfishsound-1.0.0
./configure ./configure
make -j $(getconf _NPROCESSORS_ONLN) make -j $(getconf _NPROCESSORS_ONLN)
@ -34,17 +32,17 @@ RUN EOF
make install make install
# Compile Oxframe # 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 cd /tmp/oxframe
sed -i '/man\/oxframe/d' Makefile sed -i '/man\/oxframe/d' Makefile
make make
make install make install
# Clone Pandora git repositories # Clone Pandora git repositories
git clone --depth 1 https://git.0x2620.org/pandora.git /srv/pandora git clone --depth 1 https://code.0x2620.org/0x2620/pandora.git /srv/pandora
git clone --depth 1 https://git.0x2620.org/oxjs.git /srv/pandora/static/oxjs git clone --depth 1 https://code.0x2620.org/0x2620/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://code.0x2620.org/0x2620/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/oxtimelines.git /srv/pandora/src/oxtimelines
pip3 install -e /srv/pandora/src/python-ox pip3 install -e /srv/pandora/src/python-ox
pip3 install -e /srv/pandora/src/oxtimelines pip3 install -e /srv/pandora/src/oxtimelines
pip3 install -r /srv/pandora/requirements.txt 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 adduser -S -u 8080 -h /srv/pandora -s /bin/false -g pandora -G pandora pandora
EOF EOF
COPY lxc COPY image.d
RUN EOF RUN EOF
# Update static files for Czech translation # Update static files for Czech translation

View File

@ -1,59 +1,58 @@
#!/bin/sh #!/bin/sh
set -ev 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 # Create Postgres instance
mkdir -p /srv/pandora/postgres_data install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
chown -R 105432:105432 /srv/pandora/postgres_data spoc-container exec pandora-postgres -- initdb -D /var/lib/postgresql
chmod 700 /srv/pandora/postgres_data
lxc-execute -n pandora-postgres -- initdb -D /var/lib/postgresql
# Configure Postgres # Configure Postgres
cp postgres_data/postgresql.conf /srv/pandora/postgres_data/postgresql.conf install -o 105432 -g 105432 -m 600 postgres_data/postgresql.conf ${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/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf
# Create PostgreSQL user and database # Create PostgreSQL user and database
export PANDORA_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') export PANDORA_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
service lxc-pandora-postgres start spoc-container start pandora-postgres
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 pandora-postgres -- psql envsubst <createdb.sql | spoc-container exec pandora-postgres -- psql
# Create RabbitMQ directory structure # Create RabbitMQ directory structure
mkdir -p /srv/pandora/rabbitmq_data install -o 105672 -g 105672 -m 750 -d ${RABBITMQ_DATA}
chown 105672:105672 /srv/pandora/rabbitmq_data
# Configure RabbitMQ # Configure RabbitMQ virtualhost
export PANDORA_RABBIT_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') export PANDORA_RABBIT_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
service lxc-pandora-rabbitmq start spoc-container start pandora-rabbitmq
lxc-attach pandora-rabbitmq -- rabbitmqctl add_user pandora ${PANDORA_RABBIT_PWD} spoc-container exec pandora-rabbitmq -- rabbitmqctl add_user pandora ${PANDORA_RABBIT_PWD}
lxc-attach pandora-rabbitmq -- rabbitmqctl add_vhost /pandora spoc-container exec pandora-rabbitmq -- rabbitmqctl add_vhost /pandora
lxc-attach pandora-rabbitmq -- rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*" spoc-container exec pandora-rabbitmq -- rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
# Configure Pandora # Configure Pandora
mkdir -p /srv/pandora/pandora_conf /srv/pandora/pandora_data install -o 108080 -g 108080 -m 750 -d ${PANDORA_CONF}
chown 108080:108080 /srv/pandora/pandora_data install -o 108080 -g 108080 -m 750 -d ${PANDORA_DATA}
cp pandora_conf/config.jsonc /srv/pandora/pandora_conf/config.jsonc install -o 108080 -g 108080 -m 640 pandora_conf/config.jsonc ${PANDORA_CONF}/config.jsonc
cp pandora_conf/gunicorn_config.py /srv/pandora/pandora_conf/gunicorn_config.py install -o 108080 -g 108080 -m 640 pandora_conf/gunicorn_config.py ${PANDORA_CONF}/gunicorn_config.py
envsubst <pandora_conf/local_settings.py >/srv/pandora/pandora_conf/local_settings.py envsubst <pandora_conf/local_settings.py | install -o 108080 -g 108080 -m 640 /dev/stdin ${PANDORA_CONF}/local_settings.py
chown -R 108080:108080 /srv/pandora/pandora_conf
# Populate database # Populate database
lxc-execute pandora -- /srv/pandora/pandora/manage.py migrate --noinput spoc-container exec pandora -- /srv/pandora/pandora/manage.py migrate --noinput
lxc-execute pandora -- /srv/pandora/pandora/manage.py sqlfindindex spoc-container exec pandora -- /srv/pandora/pandora/manage.py sqlfindindex
lxc-execute pandora -- /srv/pandora/pandora/manage.py sync_itemsort spoc-container exec 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 sync_documentsort
# Create admin account # Create admin account
export PANDORA_ADMIN_USER=admin export PANDORA_ADMIN_USER=admin
export PANDORA_ADMIN_EMAIL=admin@example.com export PANDORA_ADMIN_EMAIL=admin@example.com
export PANDORA_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=') 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}'))\"") 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 | lxc-attach -u 5432 -g 5432 pandora-postgres -- psql pandora envsubst <adminpwd.sql | spoc-container exec pandora-postgres -- psql pandora
# Install config update script
cp update-conf.sh /srv/pandora/update-conf.sh
# Stop services required for setup # Stop services required for setup
service lxc-pandora-postgres stop spoc-container stop pandora-postgres
service lxc-pandora-rabbitmq stop spoc-container stop pandora-rabbitmq
# Register application # Register application
vmmgr register-app pandora pandora "${PANDORA_ADMIN_USER}" "${PANDORA_ADMIN_PWD}" vmmgr register-app pandora pandora "${PANDORA_ADMIN_USER}" "${PANDORA_ADMIN_PWD}"

View File

@ -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"]
]
}
}
}

View File

@ -2,7 +2,7 @@
set -ev set -ev
# Remove persistent data # Remove persistent data
rm -rf /srv/pandora rm -rf "${VOLUMES_DIR}/pandora"
# Unregister application # Unregister application
vmmgr unregister-app pandora vmmgr unregister-app pandora