Dockerizzato progetto

This commit is contained in:
2022-08-30 13:33:35 +02:00
parent 3d22f4cc6a
commit 531b780645
21 changed files with 148 additions and 173 deletions
+1
View File
@@ -10,6 +10,7 @@ ASD_BINDIR="/home/${DDNINJA_AUTHOR}/private/${DDNINJA_BUILDNAME}/bin"
mkdir -p "/tmp/${DDNINJA_AUTHOR}/${DDNINJA_BUILDNAME}" mkdir -p "/tmp/${DDNINJA_AUTHOR}/${DDNINJA_BUILDNAME}"
chown -R www-data:www-data "/tmp/${DDNINJA_AUTHOR}/${DDNINJA_BUILDNAME}" chown -R www-data:www-data "/tmp/${DDNINJA_AUTHOR}/${DDNINJA_BUILDNAME}"
chown -R www-data:www-data /var/log/${DDNINJA_AUTHOR}
asdphp-entrypoint & wait asdphp-entrypoint & wait
exit $? exit $?
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/php
<?php
/******************************************
* Author : Riccardo Di Dato
* Created On : Tue Aug 30 2022
* File : convertStats.php
*******************************************/
require_once(dirname(__FILE__)."/../load.php");
function getModels() {
static $iteration = 0;
$size = 1000;
$ret = GlobalVariables::get("dao")->query(
StatisticModel::class,
[],
[
'skip' => $iteration * $size,
'limit' => $size
]
);
$iteration++;
return $ret;
}
exit;
// WIP
$models = getModels();
while (sizeof($models)>0) {
foreach ($models as $model) {
}
$models = getModels();
}
?>
+37 -7
View File
@@ -10,17 +10,45 @@ $project->buildName = "fdn2";
$project->defaultLocale = "it"; $project->defaultLocale = "it";
$database = new stdClass();
$database->dbName = getenv("DDNINJA_MONGO_DBNAME");
$database->user = getenv("DDNINJA_MONGO_USER");
$database->pass = getenv("DDNINJA_MONGO_PASSWORD");
$database->useAuth = $database->user != false || $database->pass != false;
$database->location = getenv("DDNINJA_MONGO_LOCATION");
if (file_exists(dirname(__FILE__)."/config.local.php") ){ if ($database->useAuth) {
require_once (dirname(__FILE__)."/config.local.php"); $database->connectionString = "mongodb://".$database->user.":".$database->pass."@".$database->location."/".$database->dbName;
} }
else if (file_exists(dirname(__FILE__)."/config.test.php") ){ else {
require_once (dirname(__FILE__)."/config.test.php"); $database->connectionString = "mongodb://".$database->location."/".$database->dbName;
}
else{
require_once (dirname(__FILE__)."/config.prod.php");
} }
$currentSystem = new stdClass();
$currentSystem->storageBaseDir = "/home/ddninja/storage"; // Il path con storage ecc in cui mettere immagini, file temporanei ecc
$currentSystem->privateBaseDir = "/home/ddninja/private"; // Il path in cui inserire la cartella con lib, task, binari ecc
$currentSystem->tmpBaseDir = "/tmp/ddninja";
$currentSystem->logBaseDir = "/var/log/ddninja"; // Il path dei log....
$currentSystem->xSendFileDir = "/tmp/xsend";
$currentSystem->apache = new StdClass();
$currentSystem->apache->user = "var-www";
$currentSystem->apache->group = "var-www";
$currentSystem->apache->workdir = "/var/www"; // Il path in cui inserire la cartella con le pagine html
$currentSystem->remoteLocationPath = getenv('ASD_PUBLIC_URL')."/";
// Deprecato in quanto CBS2 è stato dismesso
$backupSystem = new stdClass();
$backupSystem->account = "1582528f056a7ea7f391149fddc75553";
$backupSystem->passphrase = "232728b3e504a400a62a9f94893a9a962ecc6543ed7d3c293340414b259aac727f14d60a4f2cd52e228c9694a55774ff5652520b38d120a299394715247645b8293a880901162f268c8c8777a3ee9c6e410455cb4c8137f58f9d7162d45582ab363679ed456e56bf3b36d0384368b62eced40abd0fe117f04c9322f07ee33a7c";
// Deprecato in quanto CBS2 è stato dismesso
$cbs2 = new stdClass();
$cbs2->keyfile = "id_rsa_cbs_prod";
$cbs2->serverPort = "22";
// Generic voices // Generic voices
$config = new stdClass(); $config = new stdClass();
@@ -63,6 +91,8 @@ $config->paths->xsendfile = $currentSystem->xSendFileDir . "/" . $project->build
// FILES // FILES
$config->files = new StdClass(); $config->files = new StdClass();
$config->files->system_log = $config->paths->log . "/sys.log";
$config->files->core_log = $config->paths->log . "/core.log"; $config->files->core_log = $config->paths->log . "/core.log";
$config->files->dao_log = $config->paths->log . "/dao.log"; $config->files->dao_log = $config->paths->log . "/dao.log";
$config->files->task_log = $config->paths->log . "/task.log"; $config->files->task_log = $config->paths->log . "/task.log";
+6 -20
View File
@@ -1,17 +1,10 @@
<?php <?php
/* /**
Author: Riccardo Di Dato * Author: Riccardo Di Dato
Creation Date: 19/nov/2013 * Creation Date: 19/nov/2013
*/ *
* @deprecated In favore di unica config con variabili d'ambiente
*/
// $dbconn = new DatabaseConnection();
// $dbconn->dbname = "cbs";
// $dbconn->dbtype = "mysql";
// $dbconn->location = "localhost";
// $dbconn->username = "root";
// $dbconn->password = "root";
// Password mongo produzione: p14n3ll1FDN2 // Password mongo produzione: p14n3ll1FDN2
$database = new stdClass(); $database = new stdClass();
@@ -28,7 +21,6 @@ $currentSystem->tmpBaseDir = "/tmp/ddninja";
$currentSystem->logBaseDir = "/var/log/ddninja"; // Il path dei log.... $currentSystem->logBaseDir = "/var/log/ddninja"; // Il path dei log....
$currentSystem->xSendFileDir = "/tmp/xsend"; $currentSystem->xSendFileDir = "/tmp/xsend";
// $currentSystem->safeStorage = "/home/cbs/storage";
$currentSystem->apache = new StdClass(); $currentSystem->apache = new StdClass();
$currentSystem->apache->user = "var-www"; $currentSystem->apache->user = "var-www";
@@ -45,10 +37,4 @@ $cbs2 = new stdClass();
$cbs2->keyfile = "id_rsa_cbs_prod"; $cbs2->keyfile = "id_rsa_cbs_prod";
$cbs2->serverPort = "22"; $cbs2->serverPort = "22";
// $config->locations = new stdClass();
// $config->application->applicationInterfacePath = "/tnc15";
// $config->application->systemTmp = "/tmp";
?> ?>
-50
View File
@@ -1,50 +0,0 @@
<?php
/*
Author: Riccardo Di Dato
Creation Date: 14/nov/2013
*/
// $dbconn = new DatabaseConnection();
// $dbconn->dbname = "cbs";
// $dbconn->dbtype = "mysql";
// $dbconn->location = "localhost";
// $dbconn->username = "root";
// $dbconn->password = "root";
$database = new stdClass();
$database->dbName = "fdn2";
$database->user = "test";
$database->pass = "test";
$database->useAuth = false;
$database->connectionString = "mongodb://".$database->user.":".$database->pass."@localhost/".$database->dbname;
$currentSystem = new stdClass();
$currentSystem->storageBaseDir = "/home"; // Il path con storage ecc in cui mettere immagini, file temporanei ecc
$currentSystem->privateBaseDir = "/home/ddninja"; // Il path in cui inserire la cartella con lib, task, binari ecc
$currentSystem->tmpBaseDir = "/tmp/ddninja";
$currentSystem->logBaseDir = "/var/log"; // Il path dei log....
$currentSystem->xSendFileDir = "/tmp/xsend";
// $currentSystem->safeStorage = "/home/cbs/storage";
$currentSystem->apache = new StdClass();
$currentSystem->apache->user = "var-www";
$currentSystem->apache->group = "var-www";
$currentSystem->apache->workdir = "/var/www"; // Il path in cui inserire la cartella con le pagine html
$currentSystem->remoteLocationPath = "http://db.ifattidinapoli.it/";
$backupSystem = new stdClass();
$backupSystem->account = "40a911e14db8ad6faf0a0e7385e7c267";
$backupSystem->passphrase = "a54af48c2ec44bba903666b6d12290750178154a6965c9165d3b387e7fd0f14c5f2d62cb93f468be640d469c80f1260feed3ad98f5f52d52c045b0487e59981bf365f4037f6c7cb93572cdd5d20daeb8185afcc65dba1bd2067829f827d9b795451f6e5e8fafe5e1fbe29675feb93e7d208a6b53a14df5aeec62d97fbf34d56a";
$cbs2 = new stdClass();
$cbs2->keyfile = "id_rsa_cbs_test";
$cbs2->serverPort = "22";
// $config->locations = new stdClass();
// $config->application->applicationInterfacePath = "/tnc15";
// $config->application->systemTmp = "/tmp";
?>
+9 -6
View File
@@ -248,17 +248,20 @@ class GenericDao{
} }
} }
$command = new \MongoDB\Driver\Command( [ 'aggregate' => $collectionName, 'pipeline' => $pipeline ] ); $command = new \MongoDB\Driver\Command( [
'aggregate' => $collectionName,
'pipeline' => $pipeline,
'cursor' => [
'batchSize' => 100
],
'allowDiskUse' => true
] );
$cursor = $this->client->executeCommand( $this->dbName, $command ); $cursor = $this->client->executeCommand( $this->dbName, $command );
$rval = []; $rval = [];
foreach ($cursor as $ele){ // inganniamo il cursore, in realtà il risultato è uno foreach ($cursor as $ele){ // inganniamo il cursore, in realtà il risultato è uno
//TODO CHECK //TODO CHECK
if (!is_null($ele->result)){ $rval[] = json_decode( json_encode($ele) ,true );
$rval = $ele->result;
$rval = json_decode( json_encode($rval) ,true );
}
} }
return $rval; return $rval;
+12 -8
View File
@@ -5,8 +5,8 @@ Creation Date: 13/gen/2016
*/ */
class ASDSessionHandler { class ASDSessionHandler {
private static $isSessionStarted; private static $isSessionStarted = false;
private static $sessId; private static $sessId = null;
public static function getSessionId(){ public static function getSessionId(){
self::prepareToOperate(); self::prepareToOperate();
@@ -14,12 +14,12 @@ class ASDSessionHandler {
} }
private static function prepareToOperate(){ private static function prepareToOperate(){
if (!isset(self::$isSessionStarted) || !self::$isSessionStarted){ if ( !self::$isSessionStarted ){
self::$isSessionStarted = session_start(); self::$isSessionStarted = session_start();
} }
if (!isset(self::$sessId) || is_null(self::$sessId)){ if ( is_null(self::$sessId) ){
self::$sessId = session_id(); self::$sessId = session_id();
} }
} }
public static function sessionValueExists($val){ public static function sessionValueExists($val){
@@ -48,6 +48,10 @@ class ASDSessionHandler {
self::prepareToOperate(); self::prepareToOperate();
session_unset(); session_unset();
} }
private static function isApacheSession(){
return preg_match("/apache/", php_sapi_name());
}
} }
?> ?>
+3
View File
@@ -19,6 +19,9 @@ class GUIHandler {
private static $onLoadEvents = array(); private static $onLoadEvents = array();
public static function generateHtmlHeaders(array $data = array(), $admin = false){ public static function generateHtmlHeaders(array $data = array(), $admin = false){
if ($admin) {
ASDSessionHandler::getSessionId();
}
$conf = GlobalVariables::get("config"); $conf = GlobalVariables::get("config");
$title = $conf->info->projectName; $title = $conf->info->projectName;
+2 -2
View File
@@ -23,10 +23,10 @@ require_once(dirname(__FILE__)."/lib.instances.php");
require_once(dirname(__FILE__)."/gui/lib.inclusion.php"); require_once(dirname(__FILE__)."/gui/lib.inclusion.php");
require_once(dirname(__FILE__)."/logger/lib.inclusion.php");
require_once(dirname(__FILE__)."/system/lib.inclusion.php"); require_once(dirname(__FILE__)."/system/lib.inclusion.php");
require_once(dirname(__FILE__)."/logger/lib.inclusion.php");
require_once(dirname(__FILE__)."/mail/lib.inclusion.php"); require_once(dirname(__FILE__)."/mail/lib.inclusion.php");
require_once(dirname(__FILE__)."/media/lib.inclusion.php"); require_once(dirname(__FILE__)."/media/lib.inclusion.php");
+4
View File
@@ -4,11 +4,15 @@ Author: Riccardo Di Dato
Creation Date: 14/feb/2013 Creation Date: 14/feb/2013
*/ */
use ASD\FileSystemManager;
class FileLogger extends LoggingFacility{ class FileLogger extends LoggingFacility{
private $filePath; private $filePath;
public function __construct($name,$catalogManager,$filePath,$usedate=false) { public function __construct($name,$catalogManager,$filePath,$usedate=false) {
$this->filePath = $filePath; $this->filePath = $filePath;
touch($this->filePath);
chown($this->filePath, "www-data");
parent::__construct($name,$catalogManager,$usedate); parent::__construct($name,$catalogManager,$usedate);
} }
+2 -2
View File
@@ -17,11 +17,11 @@ require_once(dirname(__FILE__)."/FileLogger.php");
// |_____\___/ \__, |\__, |\___|_| |___/ // |_____\___/ \__, |\__, |\___|_| |___/
// |___/ |___/ // |___/ |___/
// //
$sysLog = new SyslogLogger("System",$systemCatalogManager,true);
$sysLog = new FileLogger("System",$systemCatalogManager,$config->files->system_log,true);
LoggingFacilityManager::addLogger( "system", $sysLog ); LoggingFacilityManager::addLogger( "system", $sysLog );
LoggingFacilityManager::getLogger("system")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG); LoggingFacilityManager::getLogger("system")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
$coreLog = new FileLogger("Core",$systemCatalogManager,$config->files->core_log,true); $coreLog = new FileLogger("Core",$systemCatalogManager,$config->files->core_log,true);
LoggingFacilityManager::addLogger( "core", $coreLog ); LoggingFacilityManager::addLogger( "core", $coreLog );
LoggingFacilityManager::getLogger("core")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG); LoggingFacilityManager::getLogger("core")->setLoggingLevel(LoggingFacility::$LEVEL_DEBUG);
+2 -1
View File
@@ -9,7 +9,7 @@ require_once(dirname(__FILE__)."/../load.php");
GUIHandler::generateHtmlHeaders(array(),true); GUIHandler::generateHtmlHeaders(array(),true);
if (AdminLoginManager::isLogged()){ if (AdminLoginManager::isLogged()) {
GUIHandler::redirect("admin/index.php"); GUIHandler::redirect("admin/index.php");
} }
@@ -25,6 +25,7 @@ if (!is_null($action) && strcmp($action,"login")==0){
$errMsg = "Invalid Data"; $errMsg = "Invalid Data";
} }
else { else {
GUIHandler::redirect("admin/index.php"); GUIHandler::redirect("admin/index.php");
} }
} }
+1 -1
View File
@@ -5,7 +5,7 @@ require_once(dirname(__FILE__)."/load.php");
try { try {
// if(UserLoginManager::isLogged()){ // if(UserLoginManager::isLogged()){
var_dump($_POST); // var_dump($_POST);
$id = PostHandler::get("id"); $id = PostHandler::get("id");
$titolo = PostHandler::get("titolo"); $titolo = PostHandler::get("titolo");
$commento = PostHandler::get("commento"); $commento = PostHandler::get("commento");
-65
View File
@@ -1,65 +0,0 @@
version: "3"
services:
mongo:
image: mongo:4.4.0
restart: "no"
networks:
db-network:
aliases:
- §PROJECT_BUILDNAME§.§ENVIRONMENT_TYPE§.database
volumes:
- §PROJECT_BUILDNAME§-db-persist:/usr/local/mongodb
webserver:
image: §PROJECT_REPOSITORY§/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§
env_file:
- environments/common/webserver.env
- environments/local/webserver.env
restart: "no"
ports:
- "8800:80"
networks:
db-network:
§PROJECT_BUILDNAME§-network:
links:
- mongo:database
volumes:
- §PROJECT_BUILDNAME§-storage:/home/§PROJECT_AUTHOR§/storage/§PROJECT_BUILDNAME§
- §PROJECT_BUILDNAME§-log:/var/log/§PROJECT_AUTHOR§/
- §DEBUG_HOST_PROJECT_FOLDER§/app/public:/var/www/§PROJECT_BUILDNAME§:ro
- §DEBUG_HOST_PROJECT_FOLDER§/app/private:/home/§PROJECT_AUTHOR§/private/§PROJECT_BUILDNAME§:ro
- §PROJECT_BUILDNAME§-job-comms:/jobComunication/
# worker:
# image: 662348923997.dkr.ecr.eu-west-1.amazonaws.com/§PROJECT_GROUP§/edenlandia-worker:§TAG_NAME§
# env_file: worker.env
# restart: "no"
# networks:
# db-network:
# §PROJECT_BUILDNAME§-network:
# links:
# - mongo:database
# volumes:
# - §PROJECT_BUILDNAME§-storage:/home/asdynamics/storage/edenlandia-worker
# - edenlandia-worker-log:/var/log/asdynamics/
# - ~/workspace-azzurro/webapps/edenlandia-worker/app/private:/home/asdynamics/private/§PROJECT_BUILDNAME§:ro
# - §PROJECT_BUILDNAME§-job-comms:/jobComunication/
memcached:
image: memcached:1.6.9-alpine
restart: "no"
networks:
§PROJECT_BUILDNAME§-network:
networks:
nginx-network:
external:
name:
nginx-network
db-network:
§PROJECT_BUILDNAME§-network:
volumes:
§PROJECT_BUILDNAME§-storage:
§PROJECT_BUILDNAME§-log:
# edenlandia-worker-log:
§PROJECT_BUILDNAME§-db-persist:
§PROJECT_BUILDNAME§-job-comms:
+2 -2
View File
@@ -1,7 +1,7 @@
version: "3" version: "3"
services: services:
mongo: mongo:
image: mongo:4.4.0 image: mongo:3
restart: "no" restart: "no"
networks: networks:
db-network: db-network:
@@ -24,7 +24,7 @@ services:
- mongo:database - mongo:database
volumes: volumes:
- §PROJECT_BUILDNAME§-storage:/home/§PROJECT_AUTHOR§/storage/§PROJECT_BUILDNAME§ - §PROJECT_BUILDNAME§-storage:/home/§PROJECT_AUTHOR§/storage/§PROJECT_BUILDNAME§
- §PROJECT_BUILDNAME§-log:/var/log/§PROJECT_AUTHOR§/ - ./webserver-logs:/var/log/§PROJECT_AUTHOR§/
- §DEBUG_HOST_PROJECT_FOLDER§/app/public:/var/www/§PROJECT_BUILDNAME§:ro - §DEBUG_HOST_PROJECT_FOLDER§/app/public:/var/www/§PROJECT_BUILDNAME§:ro
- §DEBUG_HOST_PROJECT_FOLDER§/app/private:/home/§PROJECT_AUTHOR§/private/§PROJECT_BUILDNAME§:ro - §DEBUG_HOST_PROJECT_FOLDER§/app/private:/home/§PROJECT_AUTHOR§/private/§PROJECT_BUILDNAME§:ro
- §PROJECT_BUILDNAME§-job-comms:/jobComunication/ - §PROJECT_BUILDNAME§-job-comms:/jobComunication/
+2 -2
View File
@@ -1,2 +1,2 @@
ASD_PROJECTNAME=FDN2 DDNINJA_PROJECTNAME=FDN2
ASD_BUILDNAME=fdn2 DDNINJA_BUILDNAME=fdn2
+5 -5
View File
@@ -1,7 +1,7 @@
ASD_ENVIRONMENT_NAME=local DDNINJA_ENVIRONMENT_NAME=local
ASD_IS_PRODUCTION=false DDNINJA_IS_PRODUCTION=false
ASD_MONGO_DBNAME=fdn2 DDNINJA_MONGO_DBNAME=fdn2
ASD_MONGO_LOCATION=database DDNINJA_MONGO_LOCATION=database
ASD_PUBLIC_URL=http://local.fdn2.loc:8800 DDNINJA_PUBLIC_URL=http://www.fdn2.loc:8800
@@ -0,0 +1,9 @@
DDNINJA_ENVIRONMENT_NAME=production
DDNINJA_IS_PRODUCTION=true
DDNINJA_MONGO_DBNAME=fdn2
DDNINJA_MONGO_LOCATION=database
DDNINJA_MONGO_USER=fdn2
DDNINJA_MONGO_PASSWORD=p14n3ll1FDN2
DDNINJA_PUBLIC_URL=http://www.ifattidinapoli.it
+7
View File
@@ -0,0 +1,7 @@
DDNINJA_ENVIRONMENT_NAME=test
DDNINJA_IS_PRODUCTION=false
DDNINJA_MONGO_DBNAME=fdn2_test
DDNINJA_MONGO_LOCATION=database
DDNINJA_PUBLIC_URL=http://test.ifattidinapoli.it
+2
View File
@@ -71,6 +71,8 @@ if [[ $SELECTED_MODES -ne 1 ]]; then
usage usage
fi fi
./aws-login.sh
if [[ $UNIT_MODE -eq 1 ]]; then if [[ $UNIT_MODE -eq 1 ]]; then
BUILDOPT+="u" BUILDOPT+="u"
UNITOPT="" UNITOPT=""
+1 -1
View File
@@ -87,7 +87,7 @@ if [[ $OUT_DIRECTORY == "" ]]; then
usage usage
fi fi
cp -r "$DIR/../cicd/environments" "$OUT_DIRECTORY/environments" cp -rT "$DIR/../cicd/environments" "$OUT_DIRECTORY/environments"
buildTemplate -f "$CFGFILE" -t "$STARTING_FILE" -o "$OUT_DIRECTORY/docker-compose.yml" --add TAG_NAME=$TAG buildTemplate -f "$CFGFILE" -t "$STARTING_FILE" -o "$OUT_DIRECTORY/docker-compose.yml" --add TAG_NAME=$TAG