Skip to content
This repository was archived by the owner on Apr 14, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ RUN set -xe \
&& gulp --env production \
&& bin/console assets:install \
&& mv web/ public/ \
&& bin/console cache:clear --no-warmup \
&& rm -rf .babelrc \
bower_components/ \
bower.json \
Expand All @@ -37,7 +36,6 @@ RUN set -xe \
node_modules/ \
npm-shrinkwrap.json \
package.json \
var/cache/* \
var/logs/* \
&& touch var/logs/${SYMFONY_ENV}.log \
&& mkdir -p var/sessions/ var/uploads/ \
Expand Down
24 changes: 24 additions & 0 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Symfony\Component\Config\ConfigCache;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

Expand Down Expand Up @@ -68,4 +69,27 @@ public function registerContainerConfiguration(LoaderInterface $loader)
$container->getParameterBag()->add($this->getEnvParameters());
});
}

/**
* Recompiles the container without warming up the whole cache.
*
* Can be called upon docker container start to inject custom parameters.
*/
public function compile()
{
// Load class cache
if ($this->loadClassCache) {
$this->doLoadClassCache($this->loadClassCache[0], $this->loadClassCache[1]);
}

// Initialize bundles to be able to parse configurations
$this->initializeBundles();

$class = $this->getContainerClass();
$cache = new ConfigCache($this->getCacheDir().'/'.$class.'.php', $this->debug);

$container = $this->buildContainer();
$container->compile();
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
}
}
29 changes: 29 additions & 0 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php

use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;

// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);

set_time_limit(0);

/**
* @var Composer\Autoload\ClassLoader $loader
*/
$loader = require __DIR__.'/../app/autoload.php';

$input = new ArgvInput();
$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';

if ($debug) {
Debug::enable();
}

$kernel = new AppKernel($env, $debug);

$kernel->compile();
2 changes: 1 addition & 1 deletion etc/docker/prod/app/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

bin/console cache:clear
bin/compile
chown -R www-data. var/cache/
cp -r public/* web/

Expand Down