Make Decidim SPOC-compatible

This commit is contained in:
Disassembler 2020-03-17 09:18:13 +01:00
parent 512895a6f2
commit f32b719630
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
10 changed files with 26 additions and 25 deletions

View File

@ -1,5 +1,5 @@
IMAGE decidim_0.20.0-191113
FROM alpine3.9-ruby2.6_2.6.3-190620
IMAGE decidim_0.20.0-200313
FROM alpine3.11-ruby2.6_2.6.5-200313
# https://github.com/Platoniq/decidim-install/blob/master/decidim-bionic.md
# https://github.com/Platoniq/decidim-install/blob/master/basic-config.md
@ -50,12 +50,13 @@ RUN EOF
# Install Decidim
bundle config build.nokogiri --use-system-libraries
gem install bundler:1.17.3
gem install decidim
cd /srv
decidim decidim-app
EOF
COPY lxc
COPY image.d
RUN EOF
# Install gems required by decidim

View File

@ -1,45 +1,45 @@
#!/bin/sh
set -ev
# Volumes
POSTGRES_DATA="${VOLUMES_DIR}/decidim/postgres_data"
DECIDIM_CONF="${VOLUMES_DIR}/decidim/decidim_conf"
DECIDIM_DATA="${VOLUMES_DIR}/decidim/decidim_data"
# Create Postgres instance
mkdir -p /srv/decidim/postgres_data
chown -R 105432:105432 /srv/decidim/postgres_data
chmod 700 /srv/decidim/postgres_data
lxc-execute -n decidim-postgres -- initdb -D /var/lib/postgresql
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
spoc-container exec decidim-postgres -- initdb -D /var/lib/postgresql
# Configure Postgres
cp postgres_data/postgresql.conf /srv/decidim/postgres_data/postgresql.conf
cp postgres_data/pg_hba.conf /srv/decidim/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 database
export DECIDIM_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
service lxc-decidim-postgres start
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 decidim-postgres -- psql
spoc-container start decidim-postgres
envsubst <createdb.sql | spoc-container exec decidim-postgres -- psql
# Copy existing config files into persistent storage
lxchelper extract decidim /srv/decidim-app/config /srv/decidim/decidim_conf
cp -rp ${LAYERS_DIR}/decidim_0.20.0-200313/srv/decidim-app/config ${DECIDIM_CONF}
# Configure Decidim
mkdir -p /srv/decidim/decidim_data/storage /srv/decidim/decidim_data/uploads
chown 108080:108080 /srv/decidim/decidim_data/storage /srv/decidim/decidim_data/uploads
export DECIDIM_SECRET=$(lxc-execute -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; rake secret')
cp decidim_conf/environments/production.rb /srv/decidim/decidim_conf/environments/production.rb
cp decidim_conf/initializers/decidim.rb /srv/decidim/decidim_conf/initializers/decidim.rb
envsubst <decidim_conf/application.yml >/srv/decidim/decidim_conf/application.yml
install -o 108080 -g 108080 -m 700 ${DECIDIM_DATA}/storage
install -o 108080 -g 108080 -m 700 ${DECIDIM_DATA}/uploads
export DECIDIM_SECRET=$(spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; rake secret')
install -o 108080 -g 108080 -m 640 decidim_conf/environments/production.rb ${DECIDIM_CONF}/environments/production.rb
install -o 108080 -g 108080 -m 640 decidim_conf/initializers/decidim.rb ${DECIDIM_CONF}/initializers/decidim.rb
envsubst <decidim_conf/application.yml | install -o 108080 -g 108080 -m 640 /dev/stdin ${DECIDIM_CONF}/application.yml
# Populate database
lxc-execute decidim -- sh -c 'cd /srv/decidim-app; bin/rails db:migrate'
spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails db:migrate'
# Create admin account
export DECIDIM_ADMIN_EMAIL=admin@example.com
export DECIDIM_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
envsubst <adminpwd.rb | lxc-execute decidim -- sh -c 'cd /srv/decidim-app; bin/rails console -e production'
# Install config update script
# TODO: cp update-conf.sh /srv/decidim/update-conf.sh
envsubst <adminpwd.rb | spoc-container exec -u 8080 -g 8080 decidim -- sh -c 'cd /srv/decidim-app; bin/rails console -e production'
# Stop services required for setup
service lxc-decidim-postgres stop
spoc-constainer stop decidim-postgres
# Register application
vmmgr register-app decidim decidim "${DECIDIM_ADMIN_EMAIL}" "${DECIDIM_ADMIN_PWD}"

View File

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