Make Ushahidi SPOC-compatible

This commit is contained in:
Disassembler 2020-03-24 15:15:26 +01:00
parent bd70f07f8b
commit 6cb0440d4a
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
24 changed files with 1402 additions and 2395 deletions

36
lxc-apps/ushahidi/app Normal file
View File

@ -0,0 +1,36 @@
{
"version": "4.4.1-200313",
"meta": {
"title": "Ushahidi",
"desc-cs": "Skupinová reakce na události",
"desc-en": "Group reaction to events",
"license": "GPL"
},
"containers": {
"ushahidi": {
"image": "ushahidi_4.4.1-200313",
"depends": [
"ushahidi-redis",
"ushahidi-mariadb"
],
"mounts": {
"ushahidi/ushahidi_conf/env": "srv/ushahidi/platform/.env:file",
"ushahidi/ushahidi_data": "srv/ushahidi/platform/application/media/uploads"
}
},
"ushahidi-redis": {
"image": "redis_5.0.7-200313",
"mounts": {
"ushahidi/redis_conf/redis.conf": "etc/redis.conf:file",
"ushahidi/redis_data": "var/lib/redis"
}
},
"ushahidi-mariadb": {
"image": "mariadb_10.4.12-200313",
"mounts": {
"ushahidi/mariadb_conf/my.cnf": "etc/my.cnf:file",
"ushahidi/mariadb_data": "var/lib/mysql"
}
}
}
}

22
lxc-apps/ushahidi/image Normal file
View File

@ -0,0 +1,22 @@
IMAGE ushahidi_4.4.1-200313
FROM alpine3.11-php7.3_7.3.15-200313
RUN EOF
# Install runtime dependencies
apk --no-cache add php7-curl php7-imap php7-mysqli php7-pdo_mysql
# Download Ushahidi
wget https://github.com/ushahidi/platform-client/releases/download/v4.4.1/ushahidi-platform-client-bundle-v4.4.1.tar.gz -O - | tar xzf - -C /srv
mv /srv/ushahidi-platform-client-bundle-* /srv/ushahidi
wget https://github.com/ushahidi/platform/releases/download/v4.4.1/ushahidi-platform-bundle-v4.4.1.tar.gz -O - | tar xzf - -C /srv/ushahidi
mv /srv/ushahidi/ushahidi-platform-bundle-* /srv/ushahidi/platform
# Create OS user
addgroup -S -g 8080 ushahidi
adduser -S -u 8080 -h /srv/ushahidi -s /bin/false -g ushahidi -G ushahidi ushahidi
chown -R ushahidi:ushahidi /srv/ushahidi/platform/application/logs /srv/ushahidi/platform/application/cache /srv/ushahidi/platform/application/media/uploads
EOF
COPY image.d
CMD /bin/s6-svscan /etc/services.d

View File

@ -0,0 +1,5 @@
*/10 * * * * cd /srv/ushahidi/platform; php artisan datasource:outgoing >/dev/null
*/10 * * * * cd /srv/ushahidi/platform; php artisan datasource:incoming >/dev/null
*/10 * * * * cd /srv/ushahidi/platform; php artisan savedsearch:sync >/dev/null
*/10 * * * * cd /srv/ushahidi/platform; php artisan notification:queue >/dev/null
*/10 * * * * cd /srv/ushahidi/platform; php artisan webhook:send >/dev/null

View File

@ -26,7 +26,7 @@ http {
index index.php; index index.php;
location / { location / {
try_files $uri /index.html; try_files $uri $uri/ /index.html;
} }
location /platform { location /platform {
@ -47,7 +47,7 @@ http {
location /config.json { location /config.json {
if ($request_method = 'OPTIONS') { if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Access-Control-Max-Age' 1728000; add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Type' 'text/plain charset=UTF-8';
@ -56,7 +56,7 @@ http {
} }
if ($request_method = 'GET') { if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
} }

View File

@ -1,39 +1,48 @@
#!/bin/sh #!/bin/sh
set -ev set -ev
# Volumes
MARIADB_CONF="${VOLUMES_DIR}/ushahidi/mariadb_conf"
MARIADB_DATA="${VOLUMES_DIR}/ushahidi/mariadb_data"
USHAHIDI_CONF="${VOLUMES_DIR}/ushahidi/ushahidi_conf"
USHAHIDI_DATA="${VOLUMES_DIR}/ushahidi/ushahidi_data"
# Create MariaDB instance # Create MariaDB instance
mkdir -p /srv/ushahidi/mariadb_conf /srv/ushahidi/mariadb_data install -o 100000 -g 100000 -m 755 -d ${MARIADB_CONF}
chown 103306:103306 /srv/ushahidi/mariadb_data install -o 103306 -g 103306 -m 750 -d ${MARIADB_DATA}
cp mariadb_conf/my.cnf /srv/ushahidi/mariadb_conf/my.cnf install -o 100000 -g 100000 -m 644 mariadb_conf/my.cnf ${MARIADB_CONF}/my.cnf
chown -R 100000:100000 /srv/ushahidi/mariadb_conf spoc-container exec mifosx-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --skip-test-db
lxc-execute ushahidi-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --auth-root-socket-user=mysql --skip-test-db
# Create database # Create database
export USHAHIDI_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=') export USHAHIDI_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
service lxc-ushahidi-mariadb start spoc-container start ushahidi-mariadb
envsubst <createdb.sql | lxc-attach ushahidi-mariadb -- mysql -u mysql envsubst <createdb.sql | spoc-container exec ushahidi-mariadb -- mysql
# Configure Redis
install -o 100000 -g 106379 -m 750 -d ${REDIS_CONF}
install -o 106379 -g 106379 -m 750 -d ${REDIS_DATA}
install -o 100000 -g 106379 -m 640 redis_conf/redis.conf ${REDIS_CONF}/redis.conf
spoc-container start ushahidi-redis
# Configure Ushahidi # Configure Ushahidi
mkdir -p /srv/ushahidi/ushahidi_conf /srv/ushahidi/ushahidi_data USHAHIDI_APPKEY=$(spoc-container exec ushahidi -- sh -c 'cd /srv/ushahidi/platform; php artisan key:generate')
chown 108080:108080 /srv/ushahidi/ushahidi_data install -o 108080 -g 100000 -m 750 -d ${USHAHIDI_CONF}
envsubst <ushahidi_conf/env >/srv/ushahidi/ushahidi_conf/env install -o 108080 -g 108080 -m 755 -d ${USHAHIDI_DATA}
cp ushahidi_conf/config.json /srv/ushahidi/ushahidi_conf/config.json envsubst <ushahidi_conf/env | install -o 108080 -g 100000 -m 640 /dev/stdin ${USHAHIDI_CONF}/env
chown -R 100000:100000 /srv/ushahidi/ushahidi_conf install -o 108080 -g 108080 -m 640 ushahidi_conf/config.json ${USHAHIDI_CONF}/config.json
# Populate database # Populate database
lxc-execute ushahidi -- /srv/ushahidi/platform/bin/phinx migrate -c /srv/ushahidi/platform/application/phinx.php spoc-container exec ushahidi -- sh -c 'cd /srv/ushahidi/platform; php artisan migrate'
# Create admin account # Create admin account
export USHAHIDI_ADMIN_USER=admin@example.com export USHAHIDI_ADMIN_USER=admin@example.com
export USHAHIDI_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=') export USHAHIDI_ADMIN_PWD=$(head -c 12 /dev/urandom | base64 | tr -d '+/=')
export USHAHIDI_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${USHAHIDI_ADMIN_PWD}'.encode(), bcrypt.gensalt()).decode().replace('2b', '2y'))") export USHAHIDI_ADMIN_HASH=$(python3 -c "import bcrypt; print(bcrypt.hashpw('${USHAHIDI_ADMIN_PWD}'.encode(), bcrypt.gensalt()).decode().replace('2b', '2y'))")
envsubst <adminpwd.sql | lxc-attach ushahidi-mariadb -- mysql -u mysql ushahidi envsubst <adminpwd.sql | spoc-container exec ushahidi-mariadb -- mysql ushahidi
# Install config update script
cp update-conf.sh /srv/ushahidi/update-conf.sh
# Stop services required for setup # Stop services required for setup
service lxc-ushahidi-mariadb stop spoc-container stop ushahidi-redis
spoc-container stop ushahidi-mariadb
# Register application # Register application
vmmgr register-app ushahidi ush "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}" vmmgr register-app ushahidi ush "${USHAHIDI_ADMIN_USER}" "${USHAHIDI_ADMIN_PWD}"

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
{
"backend_url": "https://ush.spotter.vm/platform",
"client_id": "ushahidiui",
"client_secret": "35e7f0bca957836d05ca0492211b0ac707671261",
"google_analytics_id": ""
}

View File

@ -1,5 +1,17 @@
APP_ENV=production
APP_DEBUG=false
APP_KEY=${USHAHIDI_APPKEY}
APP_TIMEZONE=Europe/Prague
APP_LANGUAGES=cs,en
DB_TYPE=mysql
DB_HOST=ushahidi-mariadb DB_HOST=ushahidi-mariadb
DB_NAME=ushahidi DB_NAME=ushahidi
DB_USER=ushahidi DB_USER=ushahidi
DB_PASS=${USHAHIDI_PWD} DB_PASS=${USHAHIDI_PWD}
DB_TYPE=MySQLi
CACHE_DRIVER=redis
QUEUE_DRIVER=redis
REDIS_HOST=ushahidi-redis
MAINTENANCE_MODE=0

View File

@ -1,5 +0,0 @@
*/10 * * * * cd /srv/ushahidi/platform; bin/ushahidi dataprovider outgoing >/dev/null
*/10 * * * * cd /srv/ushahidi/platform; bin/ushahidi dataprovider incoming >/dev/null
*/10 * * * * cd /srv/ushahidi/platform; bin/ushahidi savedsearch >/dev/null
*/10 * * * * cd /srv/ushahidi/platform; bin/ushahidi notification queue >/dev/null
*/10 * * * * cd /srv/ushahidi/platform; bin/ushahidi webhook send >/dev/null

View File

@ -1,11 +0,0 @@
--- original/vendor/aura/di/src/Factory.php
+++ platform/vendor/aura/di/src/Factory.php
@@ -619,7 +619,7 @@
} while ($entity = get_parent_class($entity));
// get traits from ancestor traits
- while (list($trait) = each($traits)) {
+ foreach ($traits as $trait => $_) {
foreach (class_uses($trait) as $key => $name) {
$traits[$key] = $name;
}

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
{"languages":[{"rtl":false,"pluralequation":"language.pluralequation","code":"sq-AL","name":"Albanian (Albania)","nplurals":2},{"rtl":true,"pluralequation":"language.pluralequation","code":"ar","name":"Arabic","nplurals":6},{"rtl":false,"pluralequation":"language.pluralequation","code":"zh","name":"Chinese","nplurals":1},{"rtl":false,"pluralequation":"language.pluralequation","code":"en","name":"English","nplurals":2},{"rtl":false,"pluralequation":"language.pluralequation","code":"fr","name":"French","nplurals":2},{"rtl":false,"pluralequation":"language.pluralequation","code":"de","name":"German","nplurals":2},{"rtl":false,"pluralequation":"language.pluralequation","code":"ht","name":"Haitian (Haitian Creole)","nplurals":2},{"rtl":false,"pluralequation":"language.pluralequation","code":"id","name":"Indonesian","nplurals":1},{"rtl":false,"pluralequation":"language.pluralequation","code":"it","name":"Italian","nplurals":2},{"rtl":true,"pluralequation":"language.pluralequation","code":"fa-IR","name":"Persian (Iran)","nplurals":2},{"rtl":false,"pluralequation":"language.pluralequation","code":"pt-BR","name":"Portuguese (Brazil)","nplurals":2},{"rtl":false,"pluralequation":"language.pluralequation","code":"ru","name":"Russian","nplurals":4},{"rtl":false,"pluralequation":"language.pluralequation","code":"es","name":"Spanish","nplurals":2},{"rtl":false,"pluralequation":"language.pluralequation","code":"sw","name":"Swahili","nplurals":2},{"rtl":false,"pluralequation":"language.pluralequation","code":"vi","name":"Vietnamese","nplurals":1},{"rtl":false,"pluralequation":"language.pluralequation","code":"vi-VN","name":"Vietnamese (Viet Nam)","nplurals":1},{"rtl":false,"pluralequation":"language.pluralequation","code":"cs","name":"Czech","nplurals":2}]}

View File

@ -1,34 +0,0 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Kohana Init Config
*
* @author Ushahidi Team <team@ushahidi.com>
* @package Ushahidi\Application\Config
* @copyright 2013 Ushahidi
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3)
*/
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - integer cache_life lifetime, in seconds, of items cached 60
* - boolean errors enable or disable error handling TRUE
* - boolean profile enable or disable internal profiling TRUE
* - boolean caching enable or disable internal caching FALSE
* - boolean expose set the X-Powered-By header FALSE
*/
return array(
'base_url' => '/platform',
'index_file' => FALSE,
'charset' => 'utf-8',
'errors' => TRUE,
'profile' => FALSE,
'caching' => FALSE,
);

View File

@ -1,34 +0,0 @@
IMAGE ushahidi_3.12.3-190620
FROM alpine3.9-php7.2_7.2.19-190620
RUN EOF
# Install runtime dependencies
apk --no-cache add php7-curl php7-imap php7-mysqli php7-pdo_mysql
# Download Ushahidi
wget https://github.com/ushahidi/platform-client/releases/download/v3.12.3/ushahidi-platform-client-bundle-v3.12.3.tar.gz -O /tmp/ushahidi-platform-client-bundle.tar.gz
wget https://github.com/ushahidi/platform/releases/download/v3.12.3/ushahidi-platform-bundle-v3.12.3.tar.gz -O /tmp/ushahidi-platform-bundle.tar.gz
tar xzf /tmp/ushahidi-platform-client-bundle.tar.gz -C /srv
mv /srv/ushahidi-platform-client-bundle-v3.12.3 /srv/ushahidi
tar xzf /tmp/ushahidi-platform-bundle.tar.gz -C /srv/ushahidi
mv /srv/ushahidi/ushahidi-platform-bundle-v3.12.3 /srv/ushahidi/platform
# Create OS user
addgroup -S -g 8080 ushahidi
adduser -S -u 8080 -h /srv/ushahidi -s /bin/false -g ushahidi -G ushahidi ushahidi
chown -R ushahidi:ushahidi /srv/ushahidi/platform/application/logs /srv/ushahidi/platform/application/cache /srv/ushahidi/platform/application/media/uploads
# Cleanup
rm -rf /tmp/ushahidi-platform-client-bundle.tar.gz /tmp/ushahidi-platform-bundle.tar.gz
EOF
COPY lxc
RUN EOF
# Patch Previewers
cd /srv/ushahidi
patch -p0 <aura.patch
rm aura.patch
EOF
CMD /bin/s6-svscan /etc/services.d

View File

@ -1,29 +0,0 @@
{
"version": "3.12.3-190620",
"meta": {
"title": "Ushahidi",
"desc-cs": "Skupinová reakce na události",
"desc-en": "Group reaction to events",
"license": "GPL"
},
"containers": {
"ushahidi": {
"image": "ushahidi_3.12.3-190620",
"depends": [
"ushahidi-mariadb"
],
"mounts": [
["FILE", "/srv/ushahidi/ushahidi_conf/env", "/srv/ushahidi/platform/.env"],
["FILE", "/srv/ushahidi/ushahidi_conf/config.json", "/srv/ushahidi/config.json"],
["DIR", "/srv/ushahidi/ushahidi_data", "/srv/ushahidi/platform/application/media/uploads"]
]
},
"ushahidi-mariadb": {
"image": "mariadb_10.3.15-190620",
"mounts": [
["FILE", "/srv/ushahidi/mariadb_conf/my.cnf", "/etc/my.cnf"],
["DIR", "/srv/ushahidi/mariadb_data", "/var/lib/mysql"]
]
}
}
}

View File

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

View File

@ -4,7 +4,7 @@ FROM alpine3.11-java8_8.242.08-200313
RUN EOF RUN EOF
# Install Tomcat 7 # Install Tomcat 7
wget https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.99/bin/apache-tomcat-7.0.99.tar.gz -O - | tar xzf - -C /srv wget https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.99/bin/apache-tomcat-7.0.99.tar.gz -O - | tar xzf - -C /srv
mv /srv/apache-tomcat-7.0.99 /srv/tomcat mv /srv/apache-tomcat-* /srv/tomcat
# Make catalina.sh available globally # Make catalina.sh available globally
ln -s /srv/tomcat/bin/catalina.sh /usr/bin/catalina.sh ln -s /srv/tomcat/bin/catalina.sh /usr/bin/catalina.sh

View File

@ -4,7 +4,7 @@ FROM alpine3.11-java8_8.242.08-200313
RUN EOF RUN EOF
# Install Tomcat 8.5 # Install Tomcat 8.5
wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.51/bin/apache-tomcat-8.5.51.tar.gz -O - | tar xzf - -C /srv wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.51/bin/apache-tomcat-8.5.51.tar.gz -O - | tar xzf - -C /srv
mv /srv/apache-tomcat-8.5.51 /srv/tomcat mv /srv/apache-tomcat-* /srv/tomcat
# Make catalina.sh available globally # Make catalina.sh available globally
ln -s /srv/tomcat/bin/catalina.sh /usr/bin/catalina.sh ln -s /srv/tomcat/bin/catalina.sh /usr/bin/catalina.sh