WIP: Untested, solo caricati file di test

This commit is contained in:
Riccardo Di Dato
2020-09-23 00:05:00 +02:00
parent 0c74df1983
commit d1f4f4c50c
44 changed files with 1034 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
/Dockerfile
/localEnv/run/*
+29
View File
@@ -0,0 +1,29 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "php",
"request": "launch",
"name": "Launch Running",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9013,
"runtimeExecutable": "/usr/bin/php",
"stopOnEntry": true
},
{
"type": "php",
"request": "launch",
"name": "Listen PHP Docker",
"port": 9013,
"pathMappings": {
"/var/www/contents-manager-service": "${workspaceRoot}/app/public",
"/home/asdynamics/private/contents-manager-service": "${workspaceRoot}/app/private",
"/home/asdynamics/private/asdphp": "/home/rik/workspace-php/kube/asdphpKube/app/private"
}
}
]
}
+6
View File
@@ -1,2 +1,8 @@
# Skel Job Processor
Per usare il progetto è sufficiente modificare
- File config
- Environment files in localEnv (specialmente il nome database)
- Rinominare sample.gitlab-ci.yml
- Modificare variabili in gitlab-ci.yml
- Modificare environments in gitlab-ci.yml
+12
View File
@@ -0,0 +1,12 @@
[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.revalidate_freq=360
opcache.validate_timestamps=0
opcache.preload=/var/www/§PROJECT_BUILDNAME§/load.php
opcache.preload_user=www-data
;opcache.blacklist_filename=/var/www/contents-manager-service/index.php
opcache.fast_shutdown=1
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
function exit_func {
echo "SIGTERM detected"
exit 1
}
trap exit_func SIGTERM SIGINT
ASD_BINDIR="/home/asdynamics/private/${ASD_BUILDNAME}/bin"
$ASD_BINDIR/ensureConstraints.php
if [ $? -ne 0 ]; then
echo "Impossible to ensure constraints";
exit 1;
fi
mkdir -p "/tmp/asdynamics/${ASD_BUILDNAME}"
$ASD_BINDIR/processJobs.php & wait
exit $?
+27
View File
@@ -0,0 +1,27 @@
#!/usr/local/bin/php
<?php
/*
* Questo script viene lanciato sempre dall'entrypoint, quindi va usato con cautela e deve semplicemente assicurarsi
* che i vincoli di versione siano rispettati
* generateDefaults.php
* Author: Riccardo Di Dato
* Creation Date: 09 gen 2017
*/
$buildName = getenv("ASD_BUILDNAME");
require_once ("/home/asdynamics/private/$buildName/load.php");
use ASD\DB\DaoRegistry;
try{
// $dao = DaoRegistry::getDefaultMongo();
exit(0);
}
catch (Exception $ex) {
var_dump($ex);
exit(1);
}
?>
+24
View File
@@ -0,0 +1,24 @@
#!/usr/local/bin/php
<?php
/*
* Questo dovrebbe essere uno script di inizializzazione del progetto, andrebbe usato solo una volta
*
* generateDefaults.php
* Author: Riccardo Di Dato
* Creation Date: 09 gen 2017
*/
$buildName = getenv("ASD_BUILDNAME");
require_once ("/home/asdynamics/private/$buildName/load.php");
try{
exit(0);
}
catch (Exception $ex) {
var_dump($ex);
exit(1);
}
?>
+46
View File
@@ -0,0 +1,46 @@
#!/usr/local/bin/php
<?php
/******************************************
* Author : Riccardo Di Dato
* Created On : Tue Sep 22 2020
* File : processJobs.php
*******************************************/
use ASD\Context;
use ASD\DB\DaoRegistry;
use ASD\Job\JobExecutor;
use ASD\Job\LocalFilesystemComunicationStrategy;
use ASD\Job\LogManagerLoggingStrategy;
use ASD\Job\MongoJobStorageClass;
use ASD\Job\RunnableJobFactory;
use ASD\Job\SingleJobExecutionStrategy;
$buildName = getenv("ASD_BUILDNAME");
require_once ("/home/asdynamics/private/$buildName/load.php");
try{
$jobFactory = new RunnableJobFactory();
$storageClass = new MongoJobStorageClass(DaoRegistry::getDefaultMongo(), $jobFactory);
$comStrategy = new LocalFilesystemComunicationStrategy(
Context::getEnvironment()->getFilePath("comunication.shutdown"),
Context::getEnvironment()->getFilePath("comunication.execution"),
Context::getEnvironment()->getFilePath("comunication.idle")
);
$execStrat = new SingleJobExecutionStrategy();
$logStrategy = new LogManagerLoggingStrategy("job");
$executor = new JobExecutor($storageClass, $comStrategy, $execStrat, $logStrategy );
$executor->run();
exit(0);
}
catch (Exception $ex) {
var_dump($ex);
exit(1);
}
?>
+10
View File
@@ -0,0 +1,10 @@
<?php
/*
* catalogue.en.php
* Author: Riccardo Di Dato
* Creation Date: 08 gen 2019
*/
require_once("/home/asdynamics/private/asdphp/common/catalogue.default.en.php");
?>
+10
View File
@@ -0,0 +1,10 @@
<?php
/******************************************
* Author : Riccardo Di Dato
* Created On : Wed Nov 13 2019
* File : catalogue.it.php
*******************************************/
require_once("/home/asdynamics/private/asdphp/common/catalogue.default.it.php");
?>
+22
View File
@@ -0,0 +1,22 @@
<?php
/*
Author: Riccardo Di Dato
Creation Date: 07/gen/2016
*/
// SMTP
use ASD\Context;
Context::setDefaultMultilanguageLocaleName("en");
Context::setCurrentLocale("gui","en");
Context::setCurrentLocale("system","en");
Context::setCurrentLocale("api","en");
Context::getEnvironment()->addDirectoryPath("comunication", "/jobComunication");
Context::getEnvironment()->addFilePath("comunication.shutdown", Context::getEnvironment()->getDirectoryPath("comunication")."/shutdown" );
Context::getEnvironment()->addFilePath("comunication.execution", Context::getEnvironment()->getDirectoryPath("comunication")."/execution" );
Context::getEnvironment()->addFilePath("comunication.idle", Context::getEnvironment()->getDirectoryPath("comunication")."/idle" );
?>
+26
View File
@@ -0,0 +1,26 @@
<?php
/*
* lib.inclusion.php
* Author: Riccardo Di Dato
* Creation Date: 03 lug 2020
*/
use ASD\Context;
$supportedLanguages = array("en", "it");
$commonFolder = Context::getEnvironment()->getDirectoryPath("common");
foreach ($supportedLanguages as $language){
if (file_exists($commonFolder."/catalogue.$language.php") ){
ASD\CatalogueManager::addCatalogue(
$language,
new ASD\Catalogue(
new ASD\CatalogueFileRetriever($commonFolder."/catalogue.$language.php"),
new ASD\KeyValueCatalogueTokenizer()
)
);
}
}
?>
+11
View File
@@ -0,0 +1,11 @@
<?php
/*
* Comment this file content if the service doesn't use any database
*
* Author: Riccardo Di Dato
* Creation Date: 14 dic 2016
*/
require_once(dirname(__FILE__)."/mongo/lib.config.php");
?>
+10
View File
@@ -0,0 +1,10 @@
<?php
/*
* lib.include.php
* Author: Riccardo Di Dato
* Creation Date: 18 gen 2019
*/
require_once(dirname(__FILE__)."/mongo/lib.inclusion.php");
?>
@@ -0,0 +1,9 @@
<?php
/*
* lib.include.php
* Author: Riccardo Di Dato
* Creation Date: 18 gen 2019
*/
?>
+24
View File
@@ -0,0 +1,24 @@
<?php
/*
* Comment this file content if the service doesn't use any database
*
* Author: Riccardo Di Dato
* Creation Date: 14 dic 2016
*/
use ASD\DB\DaoRegistry;
use ASD\DB\Mongo\MongoDao;
$dbName = getenv("ASD_MONGO_DBNAME");
$dbUser = getenv("ASD_MONGO_USER");
$dbPass = getenv("ASD_MONGO_PASSWORD");
$dbLocation = getenv("ASD_MONGO_LOCATION");
$connectionString = "mongodb://".$dbUser.":".$dbPass."@".$dbLocation."/".$dbName;
if ($dbUser === false || $dbPass === false) {
$connectionString = "mongodb://".$dbLocation."/".$dbName;
}
DaoRegistry::addDao(new MongoDao("main", $dbName, $connectionString), true);
?>
@@ -0,0 +1,11 @@
<?php
/*
* lib.include.php
* Author: Riccardo Di Dato
* Creation Date: 18 gen 2019
*/
require_once(dirname(__FILE__)."/models/lib.inclusion.php");
require_once(dirname(__FILE__)."/customFields/lib.inclusion.php");
?>
@@ -0,0 +1,9 @@
<?php
/*
* lib.include.php
* Author: Riccardo Di Dato
* Creation Date: 18 gen 2019
*/
?>
+22
View File
@@ -0,0 +1,22 @@
<?php
/*
* lib.inclusion.php
* Author: Riccardo Di Dato
* Creation Date: 03/lug/2020
*/
use ASD\Context;
use ASD\FileSystemManager;
use ASD\FileSystemRuleset;
// Lettura e scrittura su file system di log
FileSystemManager::addRuleset(Context::getEnvironment()->getDirectoryPath("log"), new FileSystemRuleset(FileSystemRuleset::PERMISSION_READ + FileSystemRuleset::PERMISSION_WRITE));
// Lettura e scrittura su storage
FileSystemManager::addRuleset(Context::getEnvironment()->getDirectoryPath("storage"), new FileSystemRuleset(FileSystemRuleset::PERMISSION_READ + FileSystemRuleset::PERMISSION_WRITE));
// Lettura e scrittura su tmp
FileSystemManager::addRuleset(Context::getEnvironment()->getDirectoryPath("tmp"), new FileSystemRuleset(FileSystemRuleset::PERMISSION_READ + FileSystemRuleset::PERMISSION_WRITE));
?>
+23
View File
@@ -0,0 +1,23 @@
<?php
/******************************************
* Author : Riccardo Di Dato
* Created On : Mon Jul 22 2019
* File : lib.configs.php
*******************************************/
$modules = array(
"fileSystem",
"db",
"catalogue",
"logger"
);
if (sizeof($modules)>0){
foreach ($modules as $module){
require_once(dirname(__FILE__)."/$module/lib.config.php");
}
}
date_default_timezone_set("Europe/Rome");
?>
+20
View File
@@ -0,0 +1,20 @@
<?php
/*
* lib.inclusions.php
* Author: Riccardo Di Dato
* Creation Date: 07 dic 2018
*/
// require_once(dirname(__FILE__)."/plugins/autoload.php");
$modules = [
"db"
];
if (sizeof($modules)>0){
foreach ($modules as $module){
require_once(dirname(__FILE__)."/$module/lib.inclusion.php");
}
}
?>
+26
View File
@@ -0,0 +1,26 @@
<?php
/*
* lib.inclusion.php
* Author: Riccardo Di Dato
* Creation Date: 03/lug/2020
*/
use ASD\API\Client\HttpClient;
use ASD\Context;
use ASD\Log\FileLogger;
use ASD\Log\GELFLogger;
use ASD\Log\Logger;
use ASD\Log\LogManager;
if (Context::getEnvironment()->get("name") == "local") {
LogManager::addLogger(new FileLogger("core", Context::getEnvironment()->getFilePath("log.core") , Logger::LEVEL_DEBUG));
LogManager::addLogger(new FileLogger("dao", Context::getEnvironment()->getFilePath("log.dao"), Logger::LEVEL_DEBUG));
}
else {
$httpClient = new HttpClient();
LogManager::addLogger(new GELFLogger("core", "http://graylog3:12201/gelf", $httpClient, Logger::LEVEL_NOTICE));
LogManager::addLogger(new GELFLogger("dao", "http://graylog3:12201/gelf", $httpClient, Logger::LEVEL_NOTICE));
}
?>
+17
View File
@@ -0,0 +1,17 @@
<?php
/*
* load.php
* Author: Riccardo Di Dato
* Creation Date: 01/nov/2016
*
*/
require_once("/home/asdynamics/private/asdphp/load.php");
require_once(dirname(__FILE__)."/common/config.php");
require_once(dirname(__FILE__)."/lib/lib.inclusions.php");
require_once(dirname(__FILE__)."/lib/lib.configs.php");
?>
+20
View File
@@ -0,0 +1,20 @@
<!-- ******************************************
* Author : Riccardo Di Dato
* Created On : Thu Jul 11 2019
* File : notFound.html.html
******************************************* -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="author" content="Riccardo Di Dato">
<title>Works</title>
</head>
<body>
IT WORKS!
</body>
</html>
+8
View File
@@ -0,0 +1,8 @@
<?php
/*
* Cambiare nomeProgetto col buildname del progetto
*/
$buildName = getenv("ASD_BUILDNAME");
require_once ("/home/asdynamics/private/$buildName/load.php");
?>
+32
View File
@@ -0,0 +1,32 @@
# Use a PHP runtime as a parent image
FROM 662348923997.dkr.ecr.eu-west-1.amazonaws.com/asdynamics/asdphp-kube:§ASDPHP_VERSION§
# Set the working directory to /app
WORKDIR /§PROJECT_BUILDNAME§
# Install some useful packages
ENV PACKAGES="dnsutils nano"
RUN apt-get update && \
apt-get install -yq --no-install-recommends $PACKAGES && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Copy the current directory contents into the container at /app
COPY ./app /§PROJECT_BUILDNAME§
COPY ./version /§PROJECT_BUILDNAME§
COPY ./config /§PROJECT_BUILDNAME§
COPY ./install /§PROJECT_BUILDNAME§
RUN chmod 744 /§PROJECT_BUILDNAME§/install
RUN /§PROJECT_BUILDNAME§/install
ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"]
# Make port 80 available to the world outside this container
EXPOSE 80
+34
View File
@@ -0,0 +1,34 @@
# Use a PHP runtime as a parent image
FROM 662348923997.dkr.ecr.eu-west-1.amazonaws.com/asdynamics/asdphp-kube:§ASDPHP_VERSION§
# Set the working directory to /app
WORKDIR /§PROJECT_BUILDNAME§
# Install some useful packages
ENV PACKAGES="dnsutils nano"
RUN apt-get update && \
apt-get install -yq --no-install-recommends $PACKAGES && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install XDebug
RUN pecl install xdebug | tail -n 1 | awk -F"\"" '{print $2}' > /usr/local/etc/php/conf.d/xdebug.ini
RUN echo "\n\n[XDebug]\nxdebug.remote_enable = 1\nxdebug.remote_autostart = 1\nxdebug.remote_host = §DEBUG_REMOTE_IP§\nxdebug.remote_port = §DEBUG_REMOTE_PORT§\n" >> /usr/local/etc/php/conf.d/xdebug.ini
# Copy the current directory contents into the container at /app
COPY ./app /§PROJECT_BUILDNAME§
COPY ./version /§PROJECT_BUILDNAME§
COPY ./config /§PROJECT_BUILDNAME§
COPY ./install /§PROJECT_BUILDNAME§
RUN chmod 744 /§PROJECT_BUILDNAME§/install
RUN /§PROJECT_BUILDNAME§/install
ENTRYPOINT ["§PROJECT_BUILDNAME§-entrypoint"]
# Make port 80 available to the world outside this container
EXPOSE 80
+15
View File
@@ -0,0 +1,15 @@
FROM 662348923997.dkr.ecr.eu-west-1.amazonaws.com/asdynamics/unittest/asdphp-kube:§ASDPHP_VERSION§
WORKDIR /§PROJECT_BUILDNAME§
COPY ./app /§PROJECT_BUILDNAME§
COPY ./test /test§PROJECT_BUILDNAME§
COPY ./version /§PROJECT_BUILDNAME§
COPY ./config /§PROJECT_BUILDNAME§
COPY ./test/install /§PROJECT_BUILDNAME§
RUN chmod 744 /§PROJECT_BUILDNAME§/install
RUN /§PROJECT_BUILDNAME§/install
ENTRYPOINT ["/usr/local/bin/phpunit"]
CMD ["--help"]
+88
View File
@@ -0,0 +1,88 @@
#!/bin/bash
function help() {
printf "\n"
printf "generateDockerfile [-h] [-t|b|d]\n"
printf "\n"
printf "Version name is mandatory.\n"
printf "Available options:\n"
printf "\t -h this message\n"
printf "\t -t Test dockerfile\n"
printf "\t -b Build dockerfile\n"
printf "\t -d Debug dockerfile\n"
printf "\n"
}
BUILD_VERSION=false
TEST_VERSION=false
DEBUG_VERSION=false
VERSION_ACTIVE=0
while getopts ":hbtd" optname
do
case "$optname" in
"h")
OPTION_HELP=true
;;
"b")
# This version is the running environment
STARTING_FILE="dockerfiles/build.dockerfile"
VERSION_ACTIVE=$VERSION_ACTIVE+1
;;
"t")
# This version is the unit-test only environment
STARTING_FILE="dockerfiles/test.dockerfile"
VERSION_ACTIVE=$VERSION_ACTIVE+1
;;
"d")
# This version is a running environment with x-debugger included
STARTING_FILE="dockerfiles/debug.dockerfile"
VERSION_ACTIVE=$VERSION_ACTIVE+1
;;
":")
echo "No argument value for option $OPTARG"
exit 1;
;;
*)
# Should not occur
echo "Unknown error while processing options"
;;
esac
done
if [[ $VERSION_ACTIVE -eq 0 ]]; then
echo "Impossible to run script without chosing a version between debug, test and build";
exit 1;
fi
if [[ $VERSION_ACTIVE -gt 1 ]]; then
echo "Invalid version requested, only one between -t -d and -b can be used, $VERSION_ACTIVE passed";
exit 1;
fi
my_dir="$(dirname "$0")"
DIR_RETURN=`pwd`
cd "$my_dir"
source ../config
# echo "sed -e 's/§ASDPHP_VERSION§/${ASDPHP_VERSION}/g'";
# echo "sed -e 's/§DEBUG_REMOTE_IP§/${DEBUG_REMOTE_IP}/g'";
# echo "sed -e 's/§PROJECT_BUILDNAME§/${PROJECT_BUILDNAME}/g'";
# echo "sed -e 's~§PROJECT_GROUP§~${PROJECT_GROUP}~g'";
# echo "sed -e 's/§DEBUG_REMOTE_PORT§/${DEBUG_REMOTE_PORT}/g'";
cat "$STARTING_FILE" |
sed -e "s/§ASDPHP_VERSION§/${ASDPHP_VERSION}/g" |
sed -e "s/§DEBUG_REMOTE_IP§/${DEBUG_REMOTE_IP}/g" |
sed -e "s/§PROJECT_BUILDNAME§/${PROJECT_BUILDNAME}/g" |
sed -e "s~§PROJECT_GROUP§~${PROJECT_GROUP}~g" |
sed -e "s/§DEBUG_REMOTE_PORT§/${DEBUG_REMOTE_PORT}/g" \
> "$DIR_RETURN/Dockerfile"
cd "$DIR_RETURN"
+7
View File
@@ -0,0 +1,7 @@
ASDPHP_VERSION="2.3.0-rev3"
DEBUG_REMOTE_IP="10.0.1.3"
DEBUG_REMOTE_PORT="9003"
PROJECT_GROUP="azzurro/microservices"
PROJECT_BUILDNAME="testskel-job"
PROJECT_TYPE="api"
+30
View File
@@ -0,0 +1,30 @@
#!/bin/bash
my_dir="$(dirname "$0")"
DIR_RETURN=`pwd`
cd "$my_dir"
source ./config
# Create paths
mkdir -p /home/asdynamics/{private,storage}/$PROJECT_BUILDNAME
mkdir -p /var/log/asdynamics/$PROJECT_BUILDNAME
# Copy application
cp -r ./private/* /home/asdynamics/private/$PROJECT_BUILDNAME/
# Make bin executables
chmod 0744 /home/asdynamics/private/$PROJECT_BUILDNAME/bin/*
# Overwrite opcache default config
cat ./os/opcache.template.ini |
sed -e "s/§PROJECT_BUILDNAME§/${PROJECT_BUILDNAME}/g" \
> /usr/local/etc/php/conf.d/opcache.ini
# Generate Entrypoint
cp "./os/worker-entrypoint" "/usr/local/bin/$PROJECT_BUILDNAME-entrypoint"
chmod 0744 /usr/local/bin/$PROJECT_BUILDNAME-entrypoint
cd "$DIR_RETURN"
+63
View File
@@ -0,0 +1,63 @@
#!/bin/bash
my_dir="$(dirname "$0")"
DIR_RETURN=`pwd`
cd "$my_dir"
echo "Reading project variables"
source ../config
echo "Generating run env"
mkdir -p run
cd run
USEDIR="/home/asdynamics/dockerenv/$PROJECT_BUILDNAME"
if [ ! -d "$USEDIR" ]; then
mkdir -p "$USEDIR"
fi
$(aws ecr get-login --no-include-email)
echo "Generating Dockerfile"
../../cicd/generateDockerfile.sh -d
docker build -t "662348923997.dkr.ecr.eu-west-1.amazonaws.com/$PROJECT_GROUP/$PROJECT_BUILDNAME:local" -f Dockerfile ../../
echo "Copying envinronments"
cp ../webserver.env "$USEDIR/webserver.env"
echo "Generating compose"
../generateCompose.sh -v local
cd "$USEDIR"
checkImages=(mongo worker)
COMPOSER_NAME="local_$PROJECT_BUILDNAME"
#docker-compose --log-level ERROR pull
docker-compose -p "$COMPOSER_NAME" up -d
cd "$DIR_RETURN"
sleep 5
RED='\033[0;31m'
NC='\033[0m' # No Color
GREEN='\033[0;32m'
for img in "${checkImages[@]}"
do
echo "Checking $img..."
INSTANCES=`docker ps | grep "${COMPOSER_NAME}_${img}" | wc -l`
if [[ $INSTANCES -eq 0 ]]; then
printf "${RED}ERROR! No ${img} instance found for ${COMPOSER_NAME} after composing!!!${NC}\n";
exit 1;
fi
done
printf "${GREEN}SUCCESS! All instances found after composing${NC}\n";
exit 0;
+26
View File
@@ -0,0 +1,26 @@
version: "3"
services:
mongo:
image: mongo:4.4.0
restart: "no"
networks:
db-network:
volumes:
- §PROJECT_BUILDNAME§-db-persist:/usr/local/mongodb
worker:
image: 662348923997.dkr.ecr.eu-west-1.amazonaws.com/§PROJECT_GROUP§/§PROJECT_BUILDNAME§:§TAG_NAME§
env_file: webserver.env
restart: "no"
networks:
db-network:
links:
- mongo:database
volumes:
- §PROJECT_BUILDNAME§-storage:/home/asdynamics/storage/§PROJECT_BUILDNAME§
- §PROJECT_BUILDNAME§-log:/var/log/asdynamics/
volumes:
§PROJECT_BUILDNAME§-storage:
§PROJECT_BUILDNAME§-log:
§PROJECT_BUILDNAME§-db-persist:
+73
View File
@@ -0,0 +1,73 @@
#!/bin/bash
my_dir="$(dirname "$0")"
DIR_RETURN=`pwd`
cd "$my_dir"
source ../config
PROJECT_NAME="$PROJECT_BUILDNAME"
TEMPLATE_FILE="docker-compose.yml"
function help() {
printf "\n"
printf "deploy [-h] [-t|p]\n"
printf "\n"
printf "Available options:\n"
printf "\t -h this message\n"
printf "\t -t Deploy test\n"
printf "\t -p Deploy production\n"
printf "\n"
}
TAG_NAME=""
DEPLOY_PRODUCTION=false
DEPLOY_TEST=false
FINAL_DIR=""
ENVIRONMENT_TYPE="test"
while getopts ":hptv:" optname
do
case "$optname" in
"h")
OPTION_HELP=true
;;
"v")
TAG_NAME="$OPTARG"
;;
":")
echo "No argument value for option $OPTARG"
exit 1;
;;
*)
# Should not occur
echo "Unknown error while processing options"
;;
esac
done
if [[ -z $TAG_NAME ]]; then
echo "You must pass a tagname!";
exit 1;
fi
FINAL_DIR="/home/asdynamics/dockerenv/$PROJECT_NAME"
COMPOSE_PROJECT_NAME="local_$PROJECT_NAME"
cat "$TEMPLATE_FILE" |
sed -e "s/§TAG_NAME§/${TAG_NAME}/g" |
sed -e "s/§PROJECT_BUILDNAME§/${PROJECT_BUILDNAME}/g" |
sed -e "s~§PROJECT_GROUP§~${PROJECT_GROUP}~g" |
sed -e "s/§ENVIRONMENT_TYPE§/${ENVIRONMENT_TYPE}/g" \
> "$FINAL_DIR/docker-compose.yml"
if [[ $? -ne 0 ]]; then
echo "Compose file creation failed..."
exit 1
fi
cd "$DIR_RETURN"
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
my_dir="$(dirname "$0")"
DIR_RETURN=`pwd`
cd "$my_dir"
echo "Reading project variables"
source ../config
cd "/home/asdynamics/dockerenv/$PROJECT_BUILDNAME"
COMPOSER_NAME="local_$PROJECT_BUILDNAME"
docker-compose -p "$COMPOSER_NAME" up webserver
cd "$DIR_RETURN"
exit 0;
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
my_dir="$(dirname "$0")"
DIR_RETURN=`pwd`
cd "$my_dir"
source ../config
echo "Generating run env"
mkdir -p run
cd run
$(aws ecr get-login --no-include-email)
../../cicd/generateDockerfile.sh -t
docker build -t "$PROJECT_GROUP/$PROJECT_BUILDNAME:unittest-local" -f Dockerfile ../../
docker run -e ASD_BUILDNAME="$PROJECT_BUILDNAME" -v $HOME/Scrivania/$PROJECT_BUILDNAME/:/tmp/htmlreport/ "$PROJECT_GROUP/$PROJECT_BUILDNAME:unittest-local" -v -c "/test$PROJECT_BUILDNAME/phpunit.xml"
cd "$DIR_RETURN"
+7
View File
@@ -0,0 +1,7 @@
ASD_PROJECTNAME=TestSkel
ASD_BUILDNAME=testskel
ASD_ENVIRONMENT_NAME=local
ASD_IS_PRODUCTION=false
ASD_MONGO_DBNAME=testskel
ASD_MONGO_LOCATION=database
+100
View File
@@ -0,0 +1,100 @@
variables:
PROJECT_BUILDNAME: "testskel-job"
REPO_URI: "662348923997.dkr.ecr.eu-west-1.amazonaws.com/testskel-job"
KUBE_DEPLOYMENT_NAME: "testskel-job"
KUBE_CONTAINER_NAME: "testskel-job"
stages:
- test
- build
- deploy
Run Unit:
stage: test
tags:
- docker
- x86
- aws
only:
- /^[0-9]+\.[0-9]+\.[0-9]+$/
except:
- branches
- triggers
script:
- echo "Logging into AWS"
- $(aws ecr get-login --no-include-email)
- echo "Generating Unit Test $CI_COMMIT_TAG Dockerfile"
- ./cicd/generateDockerfile.sh -t
- echo "Building Unit Test Image $PROJECT_BUILDNAME-unit:$CI_COMMIT_TAG"
- docker build -t $PROJECT_BUILDNAME-unit:$CI_COMMIT_TAG .
- echo "Running unit tests"
- docker run -e ASD_BUILDNAME="$PROJECT_BUILDNAME" $PROJECT_BUILDNAME-unit:$CI_COMMIT_TAG -c /test$PROJECT_BUILDNAME/phpunit.xml
Build image:
stage: build
tags:
- docker
- aws
- x86
only:
- /^[0-9]+\.[0-9]+\.[0-9]+$/
except:
- branches
- triggers
script:
- echo "Logging into AWS"
- $(aws ecr get-login --no-include-email)
- echo "Generating Build $CI_COMMIT_TAG Dockerfile"
- ./cicd/generateDockerfile.sh -b
- echo "Setting version file with $CI_COMMIT_TAG"
- echo "$CI_COMMIT_TAG" > version
- echo "Building image with name $REPO_URI:$CI_COMMIT_TAG"
- docker build -t $REPO_URI:$CI_COMMIT_TAG .
- echo "Pushing image"
- docker push "$REPO_URI:$CI_COMMIT_TAG" | cat
Deploy Test:
stage: deploy
tags:
- kube
- deployer
- test
only:
- /^[0-9]+\.[0-9]+\.[0-9]+$/
except:
- branches
- triggers
environment:
name: test
# url: https://$PROJECT_BUILDNAME.azzurroservice.it/test/
script:
- echo "Updating image version"
- kubectl set image deployments $KUBE_DEPLOYMENT_NAME $KUBE_CONTAINER_NAME="$REPO_URI:$CI_COMMIT_TAG"
- echo "Checking status"
- kubectl rollout status deployments $KUBE_CONTAINER_NAME
Deploy Production:
stage: deploy
tags:
- kube
- deployer
- production
only:
- /^[0-9]+\.[0-9]+\.[0-9]+$/
except:
- branches
- triggers
when: manual
environment:
name: production
# url: https://$PROJECT_BUILDNAME.azzurroservice.it/
script:
- echo "Updating image version"
- kubectl set image deployments $KUBE_DEPLOYMENT_NAME $KUBE_CONTAINER_NAME="$REPO_URI:$CI_COMMIT_TAG"
- echo "Checking status"
- kubectl rollout status deployments $KUBE_CONTAINER_NAME
+20
View File
@@ -0,0 +1,20 @@
<?php
/******************************************
* Author : Riccardo Di Dato
* Created On : Fri May 10 2019
* File : TestFake.php
*******************************************/
namespace ASD {
use \PHPUnit\Framework\TestCase;
class TestFake extends TestCase {
public function testAdd() {
$this->assertEquals(true,true);
}
}
}
?>
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
source ./config
# Create paths
mkdir -p /home/asdynamics/private/$PROJECT_BUILDNAME
mkdir -p /var/log/asdynamics/$PROJECT_BUILDNAME
# Copy stuff
cp -r ./private/* /home/asdynamics/private/$PROJECT_BUILDNAME/
+22
View File
@@ -0,0 +1,22 @@
<phpunit bootstrap="test.inclusions.php">
<testsuites>
<testsuite name="core">
<file>core/TestFake.php</file>
</testsuite>
</testsuites>
<filter>
<!-- <whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">/home/asdynamics/private/mailqueue/lib/</directory>
<exclude>
<directory suffix="lib.inclusion.php">/home/asdynamics/private/mailqueue/lib/</directory>
<directory suffix="lib.config.php">/home/asdynamics/private/mailqueue/lib/</directory>
<directory >/home/asdynamics/private/mailqueue/lib/email/</directory>
<file >/home/asdynamics/private/mailqueue/lib/lib.inclusions.php</file>
<file >/home/asdynamics/private/mailqueue/lib/lib.configs.php</file>
</exclude>
</whitelist> -->
</filter>
<logging>
<log type="coverage-html" target="/tmp/htmlreport/report.html" lowUpperBound="35" highLowerBound="70"/>
</logging>
</phpunit>
+10
View File
@@ -0,0 +1,10 @@
<?php
require_once("/testasdphp/test.inclusions.php");
$buildName = getenv("ASD_BUILDNAME");
require_once("/home/asdynamics/private/$buildName/lib/lib.inclusions.php");
require_once(dirname(__FILE__)."/utility/lib.inclusions.php");
?>
+8
View File
@@ -0,0 +1,8 @@
<?php
/*
* lib.inclusions.php
* Author: Riccardo Di Dato
* Creation Date: 09 apr 2019
*/
?>
+1
View File
@@ -0,0 +1 @@
local