From 853c3852fd610a8d6c553a84f37f96e0f82f1a0a Mon Sep 17 00:00:00 2001 From: Disassembler Date: Mon, 16 Mar 2020 19:21:08 +0100 Subject: [PATCH] Make CrisiCleanup SPOC-compatible --- lxc-apps/crisiscleanup/app | 26 ++++++++++++++++ lxc-apps/crisiscleanup/{lxcfile => image} | 12 ++++---- lxc-apps/crisiscleanup/install.sh | 37 +++++++++++------------ lxc-apps/crisiscleanup/meta | 26 ---------------- lxc-apps/crisiscleanup/uninstall.sh | 2 +- 5 files changed, 51 insertions(+), 52 deletions(-) create mode 100644 lxc-apps/crisiscleanup/app rename lxc-apps/crisiscleanup/{lxcfile => image} (85%) delete mode 100644 lxc-apps/crisiscleanup/meta diff --git a/lxc-apps/crisiscleanup/app b/lxc-apps/crisiscleanup/app new file mode 100644 index 0000000..ec8e297 --- /dev/null +++ b/lxc-apps/crisiscleanup/app @@ -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" + } + } + } +} diff --git a/lxc-apps/crisiscleanup/lxcfile b/lxc-apps/crisiscleanup/image similarity index 85% rename from lxc-apps/crisiscleanup/lxcfile rename to lxc-apps/crisiscleanup/image index cb20a66..cca0d84 100644 --- a/lxc-apps/crisiscleanup/lxcfile +++ b/lxc-apps/crisiscleanup/image @@ -1,5 +1,5 @@ -IMAGE crisiscleanup_2.2.0-190620 -FROM alpine3.8-ruby2.4_2.4.5-190620 +IMAGE crisiscleanup_2.2.0-200313 +FROM alpine3.8-ruby2.4_2.4.9-200313 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 # 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 - 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 # Install Ruby and NodeJS dependencies @@ -42,7 +42,7 @@ RUN EOF rm -rf /root/.bundle /root/.config /root/.npm EOF -USER 8080 8080 +USER cc WORKDIR /srv/crisiscleanup -CMD rails server +CMD /usr/local/bin/rails server HALT SIGTERM diff --git a/lxc-apps/crisiscleanup/install.sh b/lxc-apps/crisiscleanup/install.sh index c94929d..7a856a4 100755 --- a/lxc-apps/crisiscleanup/install.sh +++ b/lxc-apps/crisiscleanup/install.sh @@ -1,42 +1,41 @@ #!/bin/sh set -ev +# Volumes +POSTGRES_DATA="${VOLUMES_DIR}/crisiscleanup/postgres_data" +CC_CONF="${VOLUMES_DIR}/crisiscleanup/cc_conf" + # Create Postgres instance -mkdir -p /srv/crisiscleanup/postgres_data -chown -R 105432:105432 /srv/crisiscleanup/postgres_data -chmod 700 /srv/crisiscleanup/postgres_data -lxc-execute -n crisiscleanup-postgres -- initdb -D /var/lib/postgresql +install -o 105432 -g 105432 -m 700 -d ${POSTGRES_DATA} +spoc-container exec crisiscleanup-postgres -- initdb -D /var/lib/postgresql # Configure Postgres -cp postgres_data/postgresql.conf /srv/crisiscleanup/postgres_data/postgresql.conf -cp postgres_data/pg_hba.conf /srv/crisiscleanup/postgres_data/pg_hba.conf +install postgres_data/postgresql.conf ${POSTGRES_DATA}/postgresql.conf +install postgres_data/pg_hba.conf ${POSTGRES_DATA}/pg_hba.conf # Create database export CRISISCLEANUP_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') -service lxc-crisiscleanup-postgres start -envsubst /srv/crisiscleanup/cc_conf/database.yml -cp cc_conf/boot.rb /srv/crisiscleanup/cc_conf/boot.rb -cp cc_conf/initializers/devise.rb /srv/crisiscleanup/cc_conf/initializers/devise.rb -cp cc_conf/environments/production.rb /srv/crisiscleanup/cc_conf/environments/production.rb +envsubst