Commit 44aed2d9 authored by François Agneray's avatar François Agneray
Browse files

#44 => done

parent a952197c
Pipeline #2144 passed with stages
in 5 minutes and 15 seconds
......@@ -3,6 +3,7 @@ stages:
- test
- sonar
- build
- deploy
variables:
VERSION: "3.1"
......@@ -64,3 +65,13 @@ build:
only:
refs:
- develop
deploy:
image: alpine
stage: deploy
script:
- apk add --update curl
- curl -XPOST $DEV_WEBHOOK
only:
refs:
- develop
\ No newline at end of file
......@@ -5,10 +5,13 @@ RUN apt-get update \
&& apt-get install -y zlib1g zlib1g-dev libpq-dev libpq5 libzip-dev zip unzip \
&& docker-php-ext-install pgsql pdo_pgsql zip bcmath
RUN printf "\n" | pecl install apcu
RUN a2enmod rewrite
COPY . /project
COPY ./conf-dev/vhost.conf /etc/apache2/sites-available/000-default.conf
COPY ./conf-dev/php.ini /usr/local/etc/php/conf.d/app.ini
WORKDIR /project
......
......@@ -43,6 +43,15 @@ To list all operations availables just type `make` in your terminal at the root
You can find an open api documentation into the `anis-server.yaml` file.
## Production mode
To activate the production mode with no error details and doctrine cache, you must configure the following environment variables :
```
DISPLAY_ERROR_DETAILS: "false"
DATABASE_DEV_MODE: 0
```
## Few examples with curl
* To list all datasets available in the default instance => http://localhost:8080/dataset
......
......@@ -20,15 +20,24 @@ $container->set(SETTINGS, function () {
// Doctrine factory
$container->set('em', function (ContainerInterface $c) {
$settings = $c->get(SETTINGS)['database'];
$devMode = boolval($settings['dev_mode']);
$proxyDir = getcwd() . '/../doctrine-proxy';
$cache = null;
if ($devMode == false) {
$cache = new \Doctrine\Common\Cache\ApcuCache();
}
$dc = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(
array('src/Entity'),
$settings['dev_mode']
$devMode,
$proxyDir,
$cache
);
$dc->setProxyDir($settings['path_proxy']);
if ($settings['dev_mode']) {
$dc->setAutoGenerateProxyClasses(true);
$dc->setAutogenerateProxyClasses(false);
if ($devMode) {
$dc->setSQLLogger(new \Doctrine\DBAL\Logging\DebugStack());
} else {
$dc->setAutoGenerateProxyClasses(false);
$dc->setQueryCacheImpl($cache);
}
return \Doctrine\ORM\EntityManager::create($settings['connection_options'], $dc);
});
......
......@@ -4,14 +4,27 @@ require 'vendor/autoload.php';
$settings = require './app/settings.php';
$database = $settings['database'];
$devMode = boolval($database['dev_mode']);
$proxyDir = getcwd() . '/doctrine-proxy';
$cache = null;
if ($devMode == false) {
$cache = new \Doctrine\Common\Cache\ApcuCache();
}
$c = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(
array('src/Entity'),
$devMode,
$proxyDir,
$cache
);
$c->setAutoGenerateProxyClasses(false);
$c = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(array('src/Entity'), $database['dev_mode']);
$c->setProxyDir(getcwd() . '/' . $database['path_proxy']);
if ($database['dev_mode']) {
$c->setAutoGenerateProxyClasses(true);
if ($devMode) {
$c->setSQLLogger(new \Doctrine\DBAL\Logging\DebugStack());
} else {
$c->setAutoGenerateProxyClasses(false);
$c->setQueryCacheImpl($cache);
}
$em = \Doctrine\ORM\EntityManager::create($database['connection_options'], $c);
$helpers = new Symfony\Component\Console\Helper\HelperSet(array(
......
......@@ -6,8 +6,8 @@ RUN apt-get update \
&& docker-php-ext-install pgsql pdo_pgsql zip bcmath
# Install pecl modules
RUN pecl install xdebug \
&& rm -rf /tmp/pear
RUN pecl install xdebug && rm -rf /tmp/pear
RUN printf "\n" | pecl install apcu
RUN touch /var/log/xdebug_remote.log && chown www-data:www-data /var/log/xdebug_remote.log
......
......@@ -10,3 +10,6 @@ xdebug.remote_port=9900
xdebug.remote_connect_back=1
#xdebug.remote_host=host.docker.internal
xdebug.remote_log=/var/log/xdebug_remote.log
[apc]
extension=apcu.so
\ No newline at end of file
short_open_tag = Off
date.timezone = Europe/Paris
safe_mode = Off
expose_php = Off
memory_limit = 512M
upload_max_filesize = 16M
post_max_size = 16M
display_errors = Off
display_startup_errors = Off
disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signasignal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source
max_execution_time = 30
max_input_time = 60
# Opcode cache options
opcache.enable = 1
opcache.memory_consumption = 128
opcache.interned_strings_buffer=8
opcache.revalidate_freq = 0
opcache.validate_timestamps=0
opcache.max_accelerated_files=32531
opcache.save_comments=1
realpath_cache_size = 4096k
realpath_cache_ttl = 7200
extension=apcu.so
\ No newline at end of file
......@@ -6,9 +6,8 @@ services:
working_dir: /project
environment:
docker: "true"
DISPLAY_ERROR_DETAILS: 'true'
DATABASE_PATH_PROXY: "/tmp/doctrine_proxy"
DATABASE_DEV_MODE: "true"
DISPLAY_ERROR_DETAILS: "false"
DATABASE_DEV_MODE: 0
DATABASE_CO_DRIVER: "pdo_pgsql"
DATABASE_CO_HOST: "db"
DATABASE_CO_PORT: 5432
......
This diff is collapsed.
<?php
namespace DoctrineProxies\__CG__\App\Entity;
/**
* DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
*/
class CriteriaFamily extends \App\Entity\CriteriaFamily implements \Doctrine\ORM\Proxy\Proxy
{
/**
* @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with
* three parameters, being respectively the proxy object to be initialized, the method that triggered the
* initialization process and an array of ordered parameters that were passed to that method.
*
* @see \Doctrine\Common\Proxy\Proxy::__setInitializer
*/
public $__initializer__;
/**
* @var \Closure the callback responsible of loading properties that need to be copied in the cloned object
*
* @see \Doctrine\Common\Proxy\Proxy::__setCloner
*/
public $__cloner__;
/**
* @var boolean flag indicating if this object was already initialized
*
* @see \Doctrine\Common\Persistence\Proxy::__isInitialized
*/
public $__isInitialized__ = false;
/**
* @var array properties to be lazy loaded, with keys being the property
* names and values being their default values
*
* @see \Doctrine\Common\Proxy\Proxy::__getLazyProperties
*/
public static $lazyPropertiesDefaults = [];
/**
* @param \Closure $initializer
* @param \Closure $cloner
*/
public function __construct($initializer = null, $cloner = null)
{
$this->__initializer__ = $initializer;
$this->__cloner__ = $cloner;
}
/**
*
* @return array
*/
public function __sleep()
{
if ($this->__isInitialized__) {
return ['__isInitialized__', 'id', 'label', 'display', 'dataset'];
}
return ['__isInitialized__', 'id', 'label', 'display', 'dataset'];
}
/**
*
*/
public function __wakeup()
{
if ( ! $this->__isInitialized__) {
$this->__initializer__ = function (CriteriaFamily $proxy) {
$proxy->__setInitializer(null);
$proxy->__setCloner(null);
$existingProperties = get_object_vars($proxy);
foreach ($proxy->__getLazyProperties() as $property => $defaultValue) {
if ( ! array_key_exists($property, $existingProperties)) {
$proxy->$property = $defaultValue;
}
}
};
}
}
/**
*
*/
public function __clone()
{
$this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', []);
}
/**
* Forces initialization of the proxy
*/
public function __load()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, '__load', []);
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __isInitialized()
{
return $this->__isInitialized__;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __setInitialized($initialized)
{
$this->__isInitialized__ = $initialized;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __setInitializer(\Closure $initializer = null)
{
$this->__initializer__ = $initializer;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __getInitializer()
{
return $this->__initializer__;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __setCloner(\Closure $cloner = null)
{
$this->__cloner__ = $cloner;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific cloning logic
*/
public function __getCloner()
{
return $this->__cloner__;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
* @static
*/
public function __getLazyProperties()
{
return self::$lazyPropertiesDefaults;
}
/**
* {@inheritDoc}
*/
public function getId(): int
{
if ($this->__isInitialized__ === false) {
return (int) parent::getId();
}
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', []);
return parent::getId();
}
/**
* {@inheritDoc}
*/
public function getLabel(): string
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getLabel', []);
return parent::getLabel();
}
/**
* {@inheritDoc}
*/
public function setLabel(string $label): void
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setLabel', [$label]);
parent::setLabel($label);
}
/**
* {@inheritDoc}
*/
public function getDisplay(): int
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getDisplay', []);
return parent::getDisplay();
}
/**
* {@inheritDoc}
*/
public function setDisplay(int $display): void
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setDisplay', [$display]);
parent::setDisplay($display);
}
/**
* {@inheritDoc}
*/
public function jsonSerialize()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, 'jsonSerialize', []);
return parent::jsonSerialize();
}
}
<?php
namespace DoctrineProxies\__CG__\App\Entity;
/**
* DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
*/
class Database extends \App\Entity\Database implements \Doctrine\ORM\Proxy\Proxy
{
/**
* @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with
* three parameters, being respectively the proxy object to be initialized, the method that triggered the
* initialization process and an array of ordered parameters that were passed to that method.
*
* @see \Doctrine\Common\Proxy\Proxy::__setInitializer
*/
public $__initializer__;
/**
* @var \Closure the callback responsible of loading properties that need to be copied in the cloned object
*
* @see \Doctrine\Common\Proxy\Proxy::__setCloner
*/
public $__cloner__;
/**
* @var boolean flag indicating if this object was already initialized
*
* @see \Doctrine\Common\Persistence\Proxy::__isInitialized
*/
public $__isInitialized__ = false;
/**
* @var array properties to be lazy loaded, with keys being the property
* names and values being their default values
*
* @see \Doctrine\Common\Proxy\Proxy::__getLazyProperties
*/
public static $lazyPropertiesDefaults = [];
/**
* @param \Closure $initializer
* @param \Closure $cloner
*/
public function __construct($initializer = null, $cloner = null)
{
$this->__initializer__ = $initializer;
$this->__cloner__ = $cloner;
}
/**
*
* @return array
*/
public function __sleep()
{
if ($this->__isInitialized__) {
return ['__isInitialized__', 'id', 'label', 'dbname', 'type', 'host', 'port', 'login', 'password'];
}
return ['__isInitialized__', 'id', 'label', 'dbname', 'type', 'host', 'port', 'login', 'password'];
}
/**
*
*/
public function __wakeup()
{
if ( ! $this->__isInitialized__) {
$this->__initializer__ = function (Database $proxy) {
$proxy->__setInitializer(null);
$proxy->__setCloner(null);
$existingProperties = get_object_vars($proxy);
foreach ($proxy->__getLazyProperties() as $property => $defaultValue) {
if ( ! array_key_exists($property, $existingProperties)) {
$proxy->$property = $defaultValue;
}
}
};
}
}
/**
*
*/
public function __clone()
{
$this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', []);
}
/**
* Forces initialization of the proxy
*/
public function __load()
{
$this->__initializer__ && $this->__initializer__->__invoke($this, '__load', []);
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __isInitialized()
{
return $this->__isInitialized__;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __setInitialized($initialized)
{
$this->__isInitialized__ = $initialized;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __setInitializer(\Closure $initializer = null)
{
$this->__initializer__ = $initializer;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __getInitializer()
{
return $this->__initializer__;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
*/
public function __setCloner(\Closure $cloner = null)
{
$this->__cloner__ = $cloner;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific cloning logic
*/
public function __getCloner()
{
return $this->__cloner__;
}
/**
* {@inheritDoc}
* @internal generated method: use only when explicitly handling proxy specific loading logic
* @static
*/
public function __getLazyProperties()
{
return self::$lazyPropertiesDefaults;
}
/**
* {@inheritDoc}
*/
public function getId(): int
{
if ($this->__isInitialized__ === false) {
return (int) parent::getId();
}
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', []);