Make CrisiCleanup SPOC-compatible
This commit is contained in:
parent
b55a5dfdbd
commit
853c3852fd
26
lxc-apps/crisiscleanup/app
Normal file
26
lxc-apps/crisiscleanup/app
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"version": "2.2.0-200313",
|
||||||
|
"meta": {
|
||||||
|
"title": "Crisis Cleanup",
|
||||||
|
"desc-cs": "Mapování následků katastrof",
|
||||||
|
"desc-en": "Disaster relief mapping",
|
||||||
|
"license": "GPL"
|
||||||
|
},
|
||||||
|
"containers": {
|
||||||
|
"crisiscleanup": {
|
||||||
|
"image": "crisiscleanup_2.2.0-200313",
|
||||||
|
"depends": [
|
||||||
|
"crisiscleanup-postgres"
|
||||||
|
],
|
||||||
|
"mounts": {
|
||||||
|
"crisiscleanup/cc_conf": "srv/crisiscleanup/config"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"crisiscleanup-postgres": {
|
||||||
|
"image": "postgres_12.2.0-200313",
|
||||||
|
"mounts": {
|
||||||
|
"crisiscleanup/postgres_data": "var/lib/postgresql"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
IMAGE crisiscleanup_2.2.0-190620
|
IMAGE crisiscleanup_2.2.0-200313
|
||||||
FROM alpine3.8-ruby2.4_2.4.5-190620
|
FROM alpine3.8-ruby2.4_2.4.9-200313
|
||||||
|
|
||||||
ENV RAILS_ENV production
|
ENV RAILS_ENV production
|
||||||
|
|
||||||
@ -11,10 +11,10 @@ RUN EOF
|
|||||||
apk --no-cache add --virtual .deps build-base git libxml2-dev libxslt-dev linux-headers npm postgresql-dev yarn zlib-dev
|
apk --no-cache add --virtual .deps build-base git libxml2-dev libxslt-dev linux-headers npm postgresql-dev yarn zlib-dev
|
||||||
|
|
||||||
# Clone CrisisCleanup
|
# Clone CrisisCleanup
|
||||||
git clone --depth 1 https://github.com/CrisisCleanup/crisiscleanup /srv/crisiscleanup
|
git clone --depth 1 https://github.com/CrisisCleanup/crisiscleanup-2 /srv/crisiscleanup
|
||||||
|
|
||||||
# Hackfix ruby dependency versions
|
# Hackfix ruby dependency versions
|
||||||
sed -i 's/ruby "2\.4\.4"/ruby "2.4.5"/' /srv/crisiscleanup/Gemfile
|
sed -i 's/ruby "2\.4\.4"/ruby "2.4.9"/' /srv/crisiscleanup/Gemfile
|
||||||
gem install bundler:1.16.6
|
gem install bundler:1.16.6
|
||||||
|
|
||||||
# Install Ruby and NodeJS dependencies
|
# Install Ruby and NodeJS dependencies
|
||||||
@ -42,7 +42,7 @@ RUN EOF
|
|||||||
rm -rf /root/.bundle /root/.config /root/.npm
|
rm -rf /root/.bundle /root/.config /root/.npm
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
USER 8080 8080
|
USER cc
|
||||||
WORKDIR /srv/crisiscleanup
|
WORKDIR /srv/crisiscleanup
|
||||||
CMD rails server
|
CMD /usr/local/bin/rails server
|
||||||
HALT SIGTERM
|
HALT SIGTERM
|
@ -1,42 +1,41 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -ev
|
set -ev
|
||||||
|
|
||||||
|
# Volumes
|
||||||
|
POSTGRES_DATA="${VOLUMES_DIR}/crisiscleanup/postgres_data"
|
||||||
|
CC_CONF="${VOLUMES_DIR}/crisiscleanup/cc_conf"
|
||||||
|
|
||||||
# Create Postgres instance
|
# Create Postgres instance
|
||||||
mkdir -p /srv/crisiscleanup/postgres_data
|
install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA}
|
||||||
chown -R 105432:105432 /srv/crisiscleanup/postgres_data
|
spoc-container exec crisiscleanup-postgres -- initdb -D /var/lib/postgresql
|
||||||
chmod 700 /srv/crisiscleanup/postgres_data
|
|
||||||
lxc-execute -n crisiscleanup-postgres -- initdb -D /var/lib/postgresql
|
|
||||||
|
|
||||||
# Configure Postgres
|
# Configure Postgres
|
||||||
cp postgres_data/postgresql.conf /srv/crisiscleanup/postgres_data/postgresql.conf
|
install postgres_data/postgresql.conf ${POSTGRES_DATA}/postgresql.conf
|
||||||
cp postgres_data/pg_hba.conf /srv/crisiscleanup/postgres_data/pg_hba.conf
|
install postgres_data/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf
|
||||||
|
|
||||||
# Create database
|
# Create database
|
||||||
export CRISISCLEANUP_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
export CRISISCLEANUP_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
|
||||||
service lxc-crisiscleanup-postgres start
|
spoc-container start crisiscleanup-postgres
|
||||||
envsubst <createdb.sql | lxc-attach -u 5432 -g 5432 crisiscleanup-postgres -- psql
|
envsubst <createdb.sql | spoc-container exec crisiscleanup-postgres -- psql
|
||||||
|
|
||||||
# Copy existing config files into persistent storage
|
# Copy existing config files into persistent storage
|
||||||
lxchelper extract crisiscleanup /srv/crisiscleanup/config /srv/crisiscleanup/cc_conf
|
cp -rp ${LAYERS_DIR}/crisiscleanup_2.2.0-200313/srv/crisiscleanup/config ${CC_CONF}
|
||||||
|
|
||||||
# Configure CrisisCleanup
|
# Configure CrisisCleanup
|
||||||
export CRISISCLEANUP_ADMIN_USER="Admin"
|
export CRISISCLEANUP_ADMIN_USER="Admin"
|
||||||
export CRISISCLEANUP_ADMIN_EMAIL="admin@example.com"
|
export CRISISCLEANUP_ADMIN_EMAIL="admin@example.com"
|
||||||
export CRISISCLEANUP_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
export CRISISCLEANUP_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
|
||||||
envsubst <cc_conf/database.yml >/srv/crisiscleanup/cc_conf/database.yml
|
envsubst <cc_conf/database.yml | install -o 100000 -g 100000 /dev/stdin ${CC_CONF}/database.yml
|
||||||
cp cc_conf/boot.rb /srv/crisiscleanup/cc_conf/boot.rb
|
install -o 100000 -g 100000 cc_conf/boot.rb ${CC_CONF}/boot.rb
|
||||||
cp cc_conf/initializers/devise.rb /srv/crisiscleanup/cc_conf/initializers/devise.rb
|
install -o 100000 -g 100000 cc_conf/initializers/devise.rb ${CC_CONF}/initializers/devise.rb
|
||||||
cp cc_conf/environments/production.rb /srv/crisiscleanup/cc_conf/environments/production.rb
|
install -o 100000 -g 100000 cc_conf/environments/production.rb ${CC_CONF}/environments/production.rb
|
||||||
|
|
||||||
# Populate database
|
# Populate database
|
||||||
lxc-execute crisiscleanup -- rake db:schema:load
|
spoc-container exec crisiscleanup -- rake db:schema:load
|
||||||
envsubst <adminpwd.rb | lxc-execute crisiscleanup -- sh -c 'cd /srv/crisiscleanup; bin/rails console -e production'
|
envsubst <adminpwd.rb | spoc-container exec crisiscleanup -- sh -c 'cd /srv/crisiscleanup; bin/rails console -e production'
|
||||||
|
|
||||||
# Install config update script
|
|
||||||
cp update-conf.sh /srv/crisiscleanup/update-conf.sh
|
|
||||||
|
|
||||||
# Stop services required for setup
|
# Stop services required for setup
|
||||||
service lxc-crisiscleanup-postgres stop
|
spoc-container stop crisiscleanup-postgres
|
||||||
|
|
||||||
# Register application
|
# Register application
|
||||||
vmmgr register-app crisiscleanup cc "${CRISISCLEANUP_ADMIN_EMAIL}" "${CRISISCLEANUP_ADMIN_PWD}"
|
vmmgr register-app crisiscleanup cc "${CRISISCLEANUP_ADMIN_EMAIL}" "${CRISISCLEANUP_ADMIN_PWD}"
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "2.2.0-190620",
|
|
||||||
"meta": {
|
|
||||||
"title": "Crisis Cleanup",
|
|
||||||
"desc-cs": "Mapování následků katastrof",
|
|
||||||
"desc-en": "Disaster relief mapping",
|
|
||||||
"license": "GPL"
|
|
||||||
},
|
|
||||||
"containers": {
|
|
||||||
"crisiscleanup": {
|
|
||||||
"image": "crisiscleanup_2.2.0-190620",
|
|
||||||
"depends": [
|
|
||||||
"crisiscleanup-postgres"
|
|
||||||
],
|
|
||||||
"mounts": [
|
|
||||||
["DIR", "/srv/crisiscleanup/cc_conf", "/srv/crisiscleanup/config"]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"crisiscleanup-postgres": {
|
|
||||||
"image": "postgres_11.3.0-190620",
|
|
||||||
"mounts": [
|
|
||||||
["DIR", "/srv/crisiscleanup/postgres_data", "/var/lib/postgresql"]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,7 +2,7 @@
|
|||||||
set -ev
|
set -ev
|
||||||
|
|
||||||
# Remove persistent data
|
# Remove persistent data
|
||||||
rm -rf /srv/crisiscleanup
|
rm -rf "${VOLUMES_DIR}/crisiscleanup"
|
||||||
|
|
||||||
# Unregister application
|
# Unregister application
|
||||||
vmmgr unregister-app crisiscleanup
|
vmmgr unregister-app crisiscleanup
|
||||||
|
Loading…
Reference in New Issue
Block a user