Add Crismapp, closes #304

This commit is contained in:
Disassembler 2020-04-11 19:52:10 +02:00
parent 9417ad24a2
commit 1eea6c8e99
Signed by: Disassembler
GPG Key ID: 524BD33A0EE29499
15 changed files with 268 additions and 0 deletions

View File

@ -66,6 +66,9 @@ spoc-app publish ckan/app
spoc-image build -p crisiscleanup/image
spoc-app publish crisiscleanup/app
spoc-image build -p crismapp/image
spoc-app publish crismapp/app
spoc-image build -p cts/image
spoc-app publish cts/app

27
lxc-apps/crismapp/app Normal file
View File

@ -0,0 +1,27 @@
{
"version": "0.0.1-200411",
"meta": {
"title": "Crismapp",
"desc-cs": "Test",
"desc-en": "Test",
"license": "GPL"
},
"containers": {
"crismapp": {
"image": "crismapp_0.0.1-200411",
"depends": [
"crismapp-mariadb"
],
"mounts": {
"crismapp/crismapp_conf/config.php": "srv/crismapp/6/app/config.php:file"
}
},
"crismapp-mariadb": {
"image": "mariadb_10.4.12-200403",
"mounts": {
"crismapp/mariadb_conf/my.cnf": "etc/my.cnf:file",
"crismapp/mariadb_data": "var/lib/mysql"
}
}
}
}

33
lxc-apps/crismapp/image Normal file
View File

@ -0,0 +1,33 @@
IMAGE crismapp_0.0.1-200411
FROM alpine3.8-php5.6_5.6.40-200403
RUN EOF
# Install runtime dependencies
apk --no-cache add php5-mysqli php5-pdo_mysql
# Install build dependencies
apk --no-cache add --virtual .deps git
# Clone Crismapp
git clone https://github.com/rostanetek/crismapp /srv/crismapp
EOF
COPY image.d
RUN EOF
# Patch config
cd /srv/crismapp
patch -p0 </config.patch
rm /config.patch
# Create OS user
addgroup -S -g 8080 crismapp
adduser -S -u 8080 -h /srv/crismapp -s /bin/false -g crismapp -G crismapp crismapp
chown -R crismapp:crismapp /srv/crismapp
# Cleanup
apk --no-cache del .deps
find /srv/crismapp -name '.git*' -exec rm -rf {} +
EOF
CMD /bin/s6-svscan /etc/services.d

View File

@ -0,0 +1,64 @@
--- 6/app/admin/DBC.php
+++ 6/app/admin/DBC.php
@@ -16,31 +16,17 @@ class DBC
private static $instance = null;
-
- /*
- private static $host = 'wm53.wedos.net';
- private static $db = 'd61192_disert';
- private static $user = 'a61192_disert';
- private static $pass = 'jhdVu9D7';
-
- */
-
- private static $host = 'localhost';
- private static $db = 'disertace';
- private static $user = 'root';
- private static $pass = '';
-
-
public static function get()
{
if(self::$instance == null)
{
try
{
+ include ('../config.php');
self::$instance = new PDO(
- 'mysql:host='.self::$host.';dbname='.self::$db,
- self::$user,
- self::$pass,
+ 'mysql:host='.$GLOBALS['host'].';dbname='.$GLOBALS['db_name'],
+ $GLOBALS['db_user'],
+ $GLOBALS['db_password'],
array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
--- 6/app/db.php
+++ 6/app/db.php
@@ -6,22 +6,7 @@
/* rostanetek.cz */
- /*
-$GLOBALS['host'] = 'wm53.wedos.net';
-$GLOBALS['db_user'] = 'a61192_disert';
-$GLOBALS['db_password'] = 'jhdVu9D7';
-$GLOBALS['db_name'] = 'd61192_disert';
-*/
- /* localhost*/
-
-$GLOBALS['host'] = 'localhost';
-$GLOBALS['db_user'] = 'root';
-$GLOBALS['db_password'] = '';
-$GLOBALS['db_name'] = 'disertace';
-
-
-
-
+include ('config.php');
//uzivatele
define('DB_HOST', $GLOBALS['host']);

View File

@ -0,0 +1,44 @@
user nginx;
pid /run/nginx.pid;
worker_processes 1;
error_log /dev/stderr warn;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log off;
server_tokens off;
client_max_body_size 100m;
sendfile on;
tcp_nodelay on;
send_timeout 300;
server {
listen 8080;
server_name localhost;
root /srv/crismapp;
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/crismapp.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param HTTP_HOST $http_x_forwarded_host if_not_empty;
fastcgi_param HTTPS "on";
fastcgi_param REQUEST_SCHEME "https";
fastcgi_param SERVER_NAME $http_x_forwarded_server_name if_not_empty;
fastcgi_param SERVER_PORT $http_x_forwarded_server_port if_not_empty;
}
}
}

View File

@ -0,0 +1,13 @@
[global]
error_log = /proc/self/fd/2
daemonize = no
[crismapp]
catch_workers_output = yes
user = crismapp
group = crismapp
listen.owner = nginx
listen.group = nginx
listen = /var/run/crismapp.sock
pm = ondemand
pm.max_children = 16

View File

@ -0,0 +1,4 @@
#!/bin/execlineb -P
foreground { s6-svwait -d -t 3000 nginx }
foreground { s6-svwait -d -t 3000 php-fpm }

View File

@ -0,0 +1,3 @@
#!/bin/execlineb -P
nginx -g "daemon off;"

View File

@ -0,0 +1,3 @@
#!/bin/execlineb -P
php-fpm5 -F

View File

@ -0,0 +1,2 @@
<?php
header('Location: /6/app/');

32
lxc-apps/crismapp/install.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/sh
set -ev
# Volumes
MARIADB_CONF="${VOLUMES_DIR}/crismapp/mariadb_conf"
MARIADB_DATA="${VOLUMES_DIR}/crismapp/mariadb_data"
CRISMAPP_CONF="${VOLUMES_DIR}/crismapp/crismapp_conf"
CRISMAPP_LAYER="${LAYERS_DIR}/crismapp_0.0.1-200411"
# Create MariaDB instance
install -o 100000 -g 100000 -m 755 -d ${MARIADB_CONF}
install -o 103306 -g 103306 -m 750 -d ${MARIADB_DATA}
install -o 100000 -g 100000 -m 644 mariadb_conf/my.cnf ${MARIADB_CONF}/my.cnf
spoc-container exec crismapp-mariadb -- mysql_install_db --user=mysql --datadir=/var/lib/mysql --auth-root-authentication-method=socket --skip-test-db
# Create database
export CRISMAPP_PWD=$(head -c 18 /dev/urandom | base64 | tr -d '+/=')
spoc-container start crismapp-mariadb
envsubst <createdb.sql | spoc-container exec crismapp-mariadb -- mysql
# Populate database
cat ${CRISMAPP_LAYER}/srv/crismapp/6/disertace.sql | spoc-container exec crismapp-mariadb -- mysql crismapp
# Configure Crismapp
install -o 108080 -g 108080 -m 750 -d ${CRISMAPP_CONF}
envsubst <crismapp_conf/config.php | sed -e 's/§/$/g' | install -o 108080 -g 108080 -m 600 /dev/stdin ${CRISMAPP_CONF}/config.php
# Stop services required for setup
spoc-container stop crismapp-mariadb
# Register application
vmmgr register-app crismapp crismapp

View File

@ -0,0 +1,3 @@
CREATE USER 'crismapp'@'%' IDENTIFIED BY '${CRISMAPP_PWD}';
CREATE DATABASE crismapp;
GRANT ALL PRIVILEGES ON crismapp.* TO 'crismapp'@'%';

View File

@ -0,0 +1,5 @@
<?php
§GLOBALS['host'] = 'crismapp-mariadb';
§GLOBALS['db_user'] = 'crismapp';
§GLOBALS['db_password'] = '${CRISMAPP_PWD}';
§GLOBALS['db_name'] = 'crismapp';

View File

@ -0,0 +1,24 @@
[mysqld]
skip-external-locking
skip-name-resolve
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
[mysqldump]
quick
max_allowed_packet = 1M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M

8
lxc-apps/crismapp/uninstall.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
set -ev
# Remove persistent data
rm -rf "${VOLUMES_DIR}/crismapp"
# Unregister application
vmmgr unregister-app crismapp