Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47470fef2e | ||
|
|
4010c65dbc | ||
|
|
e2b8470e54 | ||
|
|
3546e51d9e | ||
|
|
7744dcabc1 | ||
|
|
9e6cb3780e | ||
|
|
afb1bff624 | ||
|
|
70a0b64c04 | ||
|
|
c772a20bf9 | ||
|
|
05987f26e9 | ||
|
|
78f68a82a3 | ||
|
|
55cb0b75b9 | ||
|
|
5cf34f1aea | ||
|
|
28c70e03bf |
@@ -6,22 +6,58 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class ImageCacheManager {
|
class ImageCacheManager {
|
||||||
|
private static $memcached = null;
|
||||||
|
|
||||||
|
const EXPIRATION_SECONDS = 2592000; // 30 * 24 * 60 * 60 -> 30 gg
|
||||||
|
|
||||||
|
private static function getMemcached() {
|
||||||
|
if (is_null(self::$memcached)) {
|
||||||
|
self::$memcached = new Memcached();
|
||||||
|
self::$memcached->addServer('memcached', 11211);
|
||||||
|
}
|
||||||
|
return self::$memcached;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getImageKey(MediaModel $media, $size) {
|
||||||
|
return self::getImageKeyById($media->id, $size);
|
||||||
|
}
|
||||||
|
private static function getImageKeyById(string $id, $size) {
|
||||||
|
return $id."-".$size."-image";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getMimeKey(MediaModel $media, $size) {
|
||||||
|
return self::getMimeKeyById($media->id, $size);
|
||||||
|
}
|
||||||
|
private static function getMimeKeyById(string $id, $size) {
|
||||||
|
return $id."-".$size."-mime";
|
||||||
|
}
|
||||||
|
|
||||||
public static function cacheImage(MediaModel $media, $size){
|
public static function cacheImage(MediaModel $media, $size){
|
||||||
self::checkValidModel($media);
|
self::checkValidModel($media);
|
||||||
$cachedPath = self::getImageCachePath($media->id, $size);
|
// $cachedPath = self::getImageCachePath($media->id, $size);
|
||||||
$mimePath = self::getImageMimePath($media->id, $size);
|
// $mimePath = self::getImageMimePath($media->id, $size);
|
||||||
$originalFilePath = self::getOriginalPath($media);
|
$originalFilePath = self::getOriginalPath($media);
|
||||||
|
|
||||||
if ( SFSManager::fileExists($cachedPath) ){
|
// if ( SFSManager::fileExists($cachedPath) ){
|
||||||
SFSManager::deleteFile($cachedPath);
|
// SFSManager::deleteFile($cachedPath);
|
||||||
SFSManager::deleteFile($mimePath);
|
// SFSManager::deleteFile($mimePath);
|
||||||
}
|
// }
|
||||||
if (!is_dir(pathinfo($cachedPath,PATHINFO_DIRNAME))){
|
// if (!is_dir(pathinfo($cachedPath,PATHINFO_DIRNAME))){
|
||||||
SFSManager::createDirectory(pathinfo($cachedPath,PATHINFO_DIRNAME));
|
// SFSManager::createDirectory(pathinfo($cachedPath,PATHINFO_DIRNAME));
|
||||||
}
|
// }
|
||||||
SFSManager::writeFile(mime_content_type($originalFilePath), $mimePath);
|
// SFSManager::writeFile(mime_content_type($originalFilePath), $mimePath);
|
||||||
SFSManager::writeFile(self::getImageContent($media, $size), $cachedPath);
|
// SFSManager::writeFile(self::getImageContent($media, $size), $cachedPath);
|
||||||
|
self::getMemcached()->set(
|
||||||
|
self::getMimeKey($media, $size),
|
||||||
|
mime_content_type($originalFilePath),
|
||||||
|
self::EXPIRATION_SECONDS
|
||||||
|
);
|
||||||
|
self::getMemcached()->set(
|
||||||
|
self::getImageKey($media, $size),
|
||||||
|
self::getImageContent($media, $size),
|
||||||
|
self::EXPIRATION_SECONDS
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,8 +66,9 @@ class ImageCacheManager {
|
|||||||
* @param int $size
|
* @param int $size
|
||||||
*/
|
*/
|
||||||
public static function isCached($id, $size){
|
public static function isCached($id, $size){
|
||||||
$cachedPath = self::getImageCachePath($id, $size);
|
return self::getMemcached()->get(self::getImageKeyById($id, $size)) ? true : false;
|
||||||
return SFSManager::fileExists($cachedPath);
|
// $cachedPath = self::getImageCachePath($id, $size);
|
||||||
|
// return SFSManager::fileExists($cachedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -43,8 +80,9 @@ class ImageCacheManager {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getMimeType($id, $size){
|
public static function getMimeType($id, $size){
|
||||||
$mimePath = self::getImageMimePath($id, $size);
|
return self::getMemcached()->get(self::getMimeKeyById($id, $size));
|
||||||
return file_get_contents($mimePath);
|
// $mimePath = self::getImageMimePath($id, $size);
|
||||||
|
// return file_get_contents($mimePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,14 +92,14 @@ class ImageCacheManager {
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getContent($id, $size){
|
public static function getContent($id, $size){
|
||||||
$cachedPath = self::getImageCachePath($id, $size);
|
return self::getMemcached()->get(self::getImageKeyById($id, $size));
|
||||||
return file_get_contents($cachedPath);
|
// $cachedPath = self::getImageCachePath($id, $size);
|
||||||
|
// return file_get_contents($cachedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function printCachedMedia($id, $size){
|
public static function printCachedMedia($id, $size) {
|
||||||
$cachedPath = self::getImageCachePath($id, $size);
|
|
||||||
header('Content-type: '.self::getMimeType($id, $size));
|
header('Content-type: '.self::getMimeType($id, $size));
|
||||||
return readfile($cachedPath);
|
echo self::getContent($id, $size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ if (array_key_exists("id",$_GET)) {
|
|||||||
$size=intval($_GET['size']);
|
$size=intval($_GET['size']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($size == 3){
|
if ($size !== MediaImage::SIZE_ORIGINAL){
|
||||||
if (!ImageCacheManager::isCached($_GET["id"], $size)){
|
if (!ImageCacheManager::isCached($_GET["id"], $size)){
|
||||||
$img = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$_GET['id']));
|
$img = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$_GET['id']));
|
||||||
if (!is_null($img)){
|
if (!is_null($img)){
|
||||||
@@ -32,8 +32,8 @@ if (array_key_exists("id",$_GET)) {
|
|||||||
else {
|
else {
|
||||||
$img = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$_GET['id']));
|
$img = GlobalVariables::get("dao")->getFirst("MediaModel",array("id"=>$_GET['id']));
|
||||||
|
|
||||||
|
$basepath = GlobalVariables::get("config")->paths->media;
|
||||||
if (!is_null($img) && file_exists($basepath."/".$img->id.".".$img->extension)){
|
if (!is_null($img) && file_exists($basepath."/".$img->id.".".$img->extension)){
|
||||||
$basepath = GlobalVariables::get("config")->paths->media;
|
|
||||||
$toMime = $basepath."/".$img->id.".".$img->extension;
|
$toMime = $basepath."/".$img->id.".".$img->extension;
|
||||||
$thumb = new Imagick($basepath."/".$img->id.".".$img->extension);
|
$thumb = new Imagick($basepath."/".$img->id.".".$img->extension);
|
||||||
|
|
||||||
|
|||||||
+12
-12
@@ -209,7 +209,7 @@ catch (Exception $ex){
|
|||||||
if(!is_null($media)){
|
if(!is_null($media)){
|
||||||
?>
|
?>
|
||||||
<div class="ansaImage mediaContent">
|
<div class="ansaImage mediaContent">
|
||||||
<?php $media->renderMedia();?>
|
<?php $media->renderMedia(['size' => MediaImage::SIZE_BIG]);?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -246,7 +246,7 @@ catch (Exception $ex){
|
|||||||
<div id="politica_<?php echo $i;?>" class="newsSummary"><?php
|
<div id="politica_<?php echo $i;?>" class="newsSummary"><?php
|
||||||
$media = DaoMediaHandler::getMainMediaFromModel($politica);
|
$media = DaoMediaHandler::getMainMediaFromModel($politica);
|
||||||
if(!is_null($media)){?>
|
if(!is_null($media)){?>
|
||||||
<div class="newsMainMedia mediaContent"><?php $media->renderMedia();?></div>
|
<div class="newsMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_BIG]);?></div>
|
||||||
<?php }?>
|
<?php }?>
|
||||||
<div class="newsTitle"><?php echo $stringTitolo;?></div>
|
<div class="newsTitle"><?php echo $stringTitolo;?></div>
|
||||||
<div class="newsSubTitle"><?php echo $string;?></div>
|
<div class="newsSubTitle"><?php echo $string;?></div>
|
||||||
@@ -276,7 +276,7 @@ catch (Exception $ex){
|
|||||||
<div id="cronaca_<?php echo $i;?>" class="newsSummary"><?php
|
<div id="cronaca_<?php echo $i;?>" class="newsSummary"><?php
|
||||||
$media = DaoMediaHandler::getMainMediaFromModel($cronaca);
|
$media = DaoMediaHandler::getMainMediaFromModel($cronaca);
|
||||||
if(!is_null($media)){?>
|
if(!is_null($media)){?>
|
||||||
<div class="newsMainMedia mediaContent"><?php $media->renderMedia();?></div>
|
<div class="newsMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_BIG]);?></div>
|
||||||
<?php }?>
|
<?php }?>
|
||||||
<div class="newsTitle"><?php echo $stringTitolo;?></div>
|
<div class="newsTitle"><?php echo $stringTitolo;?></div>
|
||||||
<div class="newsSubTitle"><?php echo $string;?></div>
|
<div class="newsSubTitle"><?php echo $string;?></div>
|
||||||
@@ -305,7 +305,7 @@ catch (Exception $ex){
|
|||||||
<div id="sport_<?php echo $i;?>" class="sportSummary"><?php
|
<div id="sport_<?php echo $i;?>" class="sportSummary"><?php
|
||||||
$media = DaoMediaHandler::getMainMediaFromModel($sport);
|
$media = DaoMediaHandler::getMainMediaFromModel($sport);
|
||||||
if(!is_null($media)){?>
|
if(!is_null($media)){?>
|
||||||
<div class="newsMainMedia mediaContent"><?php $media->renderMedia();?></div>
|
<div class="newsMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_BIG]);?></div>
|
||||||
<?php }?>
|
<?php }?>
|
||||||
<div class="newsTitle"><?php echo $stringTitolo;?></div>
|
<div class="newsTitle"><?php echo $stringTitolo;?></div>
|
||||||
<div class="newsSubTitle"><?php echo $string;?></div>
|
<div class="newsSubTitle"><?php echo $string;?></div>
|
||||||
@@ -334,7 +334,7 @@ catch (Exception $ex){
|
|||||||
<a href="<?php echo $cultura->getAbsoluteUrl();?>" id="cultura_<?php echo $i;?>" class="culturaNews"><?php
|
<a href="<?php echo $cultura->getAbsoluteUrl();?>" id="cultura_<?php echo $i;?>" class="culturaNews"><?php
|
||||||
$media = DaoMediaHandler::getMainMediaFromModel($cultura);
|
$media = DaoMediaHandler::getMainMediaFromModel($cultura);
|
||||||
if(!is_null($media)){?>
|
if(!is_null($media)){?>
|
||||||
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div>
|
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
|
||||||
<?php }?>
|
<?php }?>
|
||||||
<div class="culturaTitle"><?php echo $string;?></div>
|
<div class="culturaTitle"><?php echo $string;?></div>
|
||||||
</a>
|
</a>
|
||||||
@@ -358,7 +358,7 @@ catch (Exception $ex){
|
|||||||
<a href="<?php echo $ristoranti->getAbsoluteUrl();?>" id="ristoranti_<?php echo $i;?>" class="ristorantiBlock"><?php
|
<a href="<?php echo $ristoranti->getAbsoluteUrl();?>" id="ristoranti_<?php echo $i;?>" class="ristorantiBlock"><?php
|
||||||
$media = DaoMediaHandler::getMainMediaFromModel($ristoranti);
|
$media = DaoMediaHandler::getMainMediaFromModel($ristoranti);
|
||||||
if(!is_null($media)){?>
|
if(!is_null($media)){?>
|
||||||
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div>
|
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
|
||||||
<?php }?>
|
<?php }?>
|
||||||
<div class="ristorantiTitle"><?php echo $string;?></div>
|
<div class="ristorantiTitle"><?php echo $string;?></div>
|
||||||
</a>
|
</a>
|
||||||
@@ -381,7 +381,7 @@ catch (Exception $ex){
|
|||||||
<a href="<?php echo $salute->getAbsoluteUrl();?>" id="salute_<?php echo $i;?>" class="saluteContainer">
|
<a href="<?php echo $salute->getAbsoluteUrl();?>" id="salute_<?php echo $i;?>" class="saluteContainer">
|
||||||
<?php $media = DaoMediaHandler::getMainMediaFromModel($salute);
|
<?php $media = DaoMediaHandler::getMainMediaFromModel($salute);
|
||||||
if(!is_null($media)){?>
|
if(!is_null($media)){?>
|
||||||
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div>
|
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
|
||||||
<?php }?>
|
<?php }?>
|
||||||
<div class="saluteTitle"><?php echo $stringTitle;?></div>
|
<div class="saluteTitle"><?php echo $stringTitle;?></div>
|
||||||
</a>
|
</a>
|
||||||
@@ -430,7 +430,7 @@ catch (Exception $ex){
|
|||||||
<a href="<?php echo $gossip->getAbsoluteUrl();?>" id="gossip_<?php echo $i;?>"class="gossipContainer">
|
<a href="<?php echo $gossip->getAbsoluteUrl();?>" id="gossip_<?php echo $i;?>"class="gossipContainer">
|
||||||
<?php $media = DaoMediaHandler::getMainMediaFromModel($gossip);
|
<?php $media = DaoMediaHandler::getMainMediaFromModel($gossip);
|
||||||
if(!is_null($media)){?>
|
if(!is_null($media)){?>
|
||||||
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div>
|
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
|
||||||
<?php }?>
|
<?php }?>
|
||||||
<div class="gossipTitle"><?php echo $stringTitle;?></div>
|
<div class="gossipTitle"><?php echo $stringTitle;?></div>
|
||||||
</a>
|
</a>
|
||||||
@@ -455,7 +455,7 @@ catch (Exception $ex){
|
|||||||
<a href="<?php echo $professioni->getAbsoluteUrl();?>" id="gossip_<?php echo $i;?>"class="gossipContainer">
|
<a href="<?php echo $professioni->getAbsoluteUrl();?>" id="gossip_<?php echo $i;?>"class="gossipContainer">
|
||||||
<?php $media = DaoMediaHandler::getMainMediaFromModel($professioni);
|
<?php $media = DaoMediaHandler::getMainMediaFromModel($professioni);
|
||||||
if(!is_null($media)){?>
|
if(!is_null($media)){?>
|
||||||
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div>
|
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
|
||||||
<?php }?>
|
<?php }?>
|
||||||
<div class="gossipTitle"><?php echo $stringTitle;?></div>
|
<div class="gossipTitle"><?php echo $stringTitle;?></div>
|
||||||
</a>
|
</a>
|
||||||
@@ -479,7 +479,7 @@ catch (Exception $ex){
|
|||||||
<a href="<?php echo $elezioni->getAbsoluteUrl();?>" class="animaliContainer">
|
<a href="<?php echo $elezioni->getAbsoluteUrl();?>" class="animaliContainer">
|
||||||
<?php $media = DaoMediaHandler::getMainMediaFromModel($elezioni);
|
<?php $media = DaoMediaHandler::getMainMediaFromModel($elezioni);
|
||||||
if(!is_null($media)){?>
|
if(!is_null($media)){?>
|
||||||
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div>
|
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
|
||||||
<?php }?>
|
<?php }?>
|
||||||
<div class="viaggiTitle"><?php echo $stringTitle;?></div>
|
<div class="viaggiTitle"><?php echo $stringTitle;?></div>
|
||||||
</a>
|
</a>
|
||||||
@@ -503,7 +503,7 @@ catch (Exception $ex){
|
|||||||
<a href="<?php echo $viaggi->getAbsoluteUrl();?>" id="viaggi_<?php echo $i;?>"class="animaliContainer">
|
<a href="<?php echo $viaggi->getAbsoluteUrl();?>" id="viaggi_<?php echo $i;?>"class="animaliContainer">
|
||||||
<?php $media = DaoMediaHandler::getMainMediaFromModel($viaggi);
|
<?php $media = DaoMediaHandler::getMainMediaFromModel($viaggi);
|
||||||
if(!is_null($media)){?>
|
if(!is_null($media)){?>
|
||||||
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div>
|
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
|
||||||
<?php }?>
|
<?php }?>
|
||||||
<div class="viaggiTitle"><?php echo $stringTitle;?></div>
|
<div class="viaggiTitle"><?php echo $stringTitle;?></div>
|
||||||
</a>
|
</a>
|
||||||
@@ -525,7 +525,7 @@ catch (Exception $ex){
|
|||||||
<a href="<?php echo $animalNews->getAbsoluteUrl();?>" class="animaliContainer">
|
<a href="<?php echo $animalNews->getAbsoluteUrl();?>" class="animaliContainer">
|
||||||
<?php $media = DaoMediaHandler::getMainMediaFromModel($animalNews);
|
<?php $media = DaoMediaHandler::getMainMediaFromModel($animalNews);
|
||||||
if(!is_null($media)){?>
|
if(!is_null($media)){?>
|
||||||
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia();?></div>
|
<div class="culturaMainMedia mediaContent"><?php $media->renderMedia(['size' => MediaImage::SIZE_MEDIUM]);?></div>
|
||||||
<?php }?>
|
<?php }?>
|
||||||
<div class="animaliTitle"><?php echo $stringTitle;?></div>
|
<div class="animaliTitle"><?php echo $stringTitle;?></div>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -13,19 +13,20 @@ services:
|
|||||||
max-file: "5"
|
max-file: "5"
|
||||||
max-size: "50m"
|
max-size: "50m"
|
||||||
webserver:
|
webserver:
|
||||||
image: §PROJECT_REPOSITORY§/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§
|
image: §PROJECT_REPOSITORY§/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§-webserver
|
||||||
env_file:
|
env_file:
|
||||||
- environments/common/webserver.env
|
- environments/common/webserver.env
|
||||||
- environments/production/webserver.env
|
- environments/§ENVIRONMENT_TYPE§/webserver.env
|
||||||
depends_on:
|
depends_on:
|
||||||
- mongo
|
- mongo
|
||||||
- memcached
|
- memcached
|
||||||
restart: "on-failure:3"
|
restart: "on-failure:3"
|
||||||
ports:
|
|
||||||
- "80:80"
|
|
||||||
networks:
|
networks:
|
||||||
db-network:
|
db-network:
|
||||||
§PROJECT_BUILDNAME§-network:
|
§PROJECT_BUILDNAME§-network:
|
||||||
|
nginx-network:
|
||||||
|
aliases:
|
||||||
|
- §PROJECT_BUILDNAME§.§ENVIRONMENT_TYPE§.webserver
|
||||||
links:
|
links:
|
||||||
- mongo:database
|
- mongo:database
|
||||||
volumes:
|
volumes:
|
||||||
@@ -65,6 +66,10 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
db-network:
|
db-network:
|
||||||
§PROJECT_BUILDNAME§-network:
|
§PROJECT_BUILDNAME§-network:
|
||||||
|
nginx-network:
|
||||||
|
external: true
|
||||||
|
name:
|
||||||
|
nginx-network
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
@@ -3,7 +3,5 @@ DDNINJA_IS_PRODUCTION=true
|
|||||||
|
|
||||||
DDNINJA_MONGO_DBNAME=fdn2
|
DDNINJA_MONGO_DBNAME=fdn2
|
||||||
DDNINJA_MONGO_LOCATION=database
|
DDNINJA_MONGO_LOCATION=database
|
||||||
DDNINJA_MONGO_USER=fdn2
|
|
||||||
DDNINJA_MONGO_PASSWORD=p14n3ll1FDN2
|
|
||||||
|
|
||||||
DDNINJA_PUBLIC_URL=http://www.ifattidinapoli.it
|
DDNINJA_PUBLIC_URL=http://preproduction.ifattidinapoli.it
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
nginx:
|
||||||
|
image: nginx:1.16
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
networks:
|
||||||
|
- nginx-network
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
|
|
||||||
|
|
||||||
|
networks:
|
||||||
|
nginx-network:
|
||||||
|
external: true
|
||||||
|
name:
|
||||||
|
nginx-network
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
worker_processes 1;
|
||||||
|
|
||||||
|
events { worker_connections 1024; }
|
||||||
|
|
||||||
|
http {
|
||||||
|
client_max_body_size 5M;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name www.ifattidinapoli.it preproduction.ifattidinapoli.it default_server;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://fdn2.production.webserver/;
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name test.ifattidinapoli.it;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://fdn2.test.webserver/;
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+19
-5
@@ -22,6 +22,7 @@ usage() {
|
|||||||
echo " -u: Unit tests locally" 1>&2;
|
echo " -u: Unit tests locally" 1>&2;
|
||||||
echo " -d: Run debug vesion locally" 1>&2;
|
echo " -d: Run debug vesion locally" 1>&2;
|
||||||
echo " -p: Publish (requires a version)" 1>&2;
|
echo " -p: Publish (requires a version)" 1>&2;
|
||||||
|
echo " -X: Staging Deploy (requires a version)" 1>&2;
|
||||||
echo " -x: Production Deploy (requires a version)" 1>&2;
|
echo " -x: Production Deploy (requires a version)" 1>&2;
|
||||||
echo " -t: Software version, this will be used for the docker tag (default: local)" 1>&2;
|
echo " -t: Software version, this will be used for the docker tag (default: local)" 1>&2;
|
||||||
echo " -v: Verbose" 1>&2;
|
echo " -v: Verbose" 1>&2;
|
||||||
@@ -31,12 +32,13 @@ usage() {
|
|||||||
UNIT_MODE=0
|
UNIT_MODE=0
|
||||||
DEBUG_MODE=0
|
DEBUG_MODE=0
|
||||||
PUBLISH_MODE=0
|
PUBLISH_MODE=0
|
||||||
DEPLOY_MODE=0
|
DEPLOY_TEST_MODE=0
|
||||||
|
DEPLOY_PROD_MODE=0
|
||||||
SELECTED_MODES=0
|
SELECTED_MODES=0
|
||||||
|
|
||||||
TAG="local"
|
TAG="local"
|
||||||
|
|
||||||
while getopts "t:hvudpx" o; do
|
while getopts "t:hvudpxX" o; do
|
||||||
case "${o}" in
|
case "${o}" in
|
||||||
u)
|
u)
|
||||||
UNIT_MODE=1
|
UNIT_MODE=1
|
||||||
@@ -50,8 +52,12 @@ while getopts "t:hvudpx" o; do
|
|||||||
PUBLISH_MODE=1
|
PUBLISH_MODE=1
|
||||||
SELECTED_MODES+=1
|
SELECTED_MODES+=1
|
||||||
;;
|
;;
|
||||||
|
X)
|
||||||
|
DEPLOY_TEST_MODE=1
|
||||||
|
SELECTED_MODES+=1
|
||||||
|
;;
|
||||||
x)
|
x)
|
||||||
DEPLOY_MODE=1
|
DEPLOY_PROD_MODE=1
|
||||||
SELECTED_MODES+=1
|
SELECTED_MODES+=1
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -134,9 +140,17 @@ if [[ $DEBUG_MODE -eq 1 ]]; then
|
|||||||
xdg-open "$DDNINJA_PUBLIC_URL"
|
xdg-open "$DDNINJA_PUBLIC_URL"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $DEPLOY_TEST_MODE -eq 1 ]]; then
|
||||||
|
OUT_FOLDER="/home/$PROJECT_AUTHOR/$PROJECT_BUILDNAME/test"
|
||||||
|
mkdir -p $OUT_FOLDER
|
||||||
|
./generateComposeFolder.sh -s -o "$OUT_FOLDER" -t $TAG
|
||||||
|
|
||||||
if [[ $DEPLOY_MODE -eq 1 ]]; then
|
cd "$OUT_FOLDER"
|
||||||
OUT_FOLDER="/home/$PROJECT_AUTHOR/$PROJECT_BUILDNAME/local"
|
docker compose up -d
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $DEPLOY_PROD_MODE -eq 1 ]]; then
|
||||||
|
OUT_FOLDER="/home/$PROJECT_AUTHOR/$PROJECT_BUILDNAME/production"
|
||||||
mkdir -p $OUT_FOLDER
|
mkdir -p $OUT_FOLDER
|
||||||
./generateComposeFolder.sh -p -o "$OUT_FOLDER" -t $TAG
|
./generateComposeFolder.sh -p -o "$OUT_FOLDER" -t $TAG
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ usage() {
|
|||||||
STARTING_FILE=""
|
STARTING_FILE=""
|
||||||
CFGFILE="$DIR/../config"
|
CFGFILE="$DIR/../config"
|
||||||
OUT_DIRECTORY=""
|
OUT_DIRECTORY=""
|
||||||
|
ENV_TYPE="local"
|
||||||
|
|
||||||
SELECTED_MODES=0
|
SELECTED_MODES=0
|
||||||
|
|
||||||
@@ -47,11 +48,13 @@ while getopts "i:o:t:hvlLsp" o; do
|
|||||||
SELECTED_MODES+=1
|
SELECTED_MODES+=1
|
||||||
;;
|
;;
|
||||||
s)
|
s)
|
||||||
STARTING_FILE="$DIR/../cicd/docker-compose/test.yml"
|
STARTING_FILE="$DIR/../cicd/docker-compose/deploy.yml"
|
||||||
|
ENV_TYPE="test"
|
||||||
SELECTED_MODES+=1
|
SELECTED_MODES+=1
|
||||||
;;
|
;;
|
||||||
p)
|
p)
|
||||||
STARTING_FILE="$DIR/../cicd/docker-compose/production.yml"
|
STARTING_FILE="$DIR/../cicd/docker-compose/deploy.yml"
|
||||||
|
ENV_TYPE="production"
|
||||||
SELECTED_MODES+=1
|
SELECTED_MODES+=1
|
||||||
;;
|
;;
|
||||||
i)
|
i)
|
||||||
@@ -89,5 +92,5 @@ fi
|
|||||||
|
|
||||||
cp -rT "$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 --add ENVIRONMENT_TYPE=$ENV_TYPE
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user