Skip to content

Commit

Permalink
opcache
Browse files Browse the repository at this point in the history
  • Loading branch information
fabio-ivona committed Dec 15, 2023
1 parent deec2cc commit 63c5356
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
13 changes: 12 additions & 1 deletion app/Containers/Php.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ class Php extends Container
'context' => 'https://github.com/defstudio/docker-php.git',
'target' => 'fpm',
'args' => [
'PRODUCTION' => 0,
'ENABLE_XDEBUG' => 0,
'ENABLE_LIBREOFFICE_WRITER' => 0,
'ENABLE_BACKUP_TOOLS' => 0,
'PRODUCTION' => 0,
'ENABLE_OPCACHE' => 0,
],
],
'expose' => [9000],
Expand All @@ -41,6 +42,12 @@ public function set_version($version): self
return $this;
}

public function enable_opcache(bool $enabled = true): self
{
$this->set_service_definition('build.args.ENABLE_OPCACHE', $enabled ? 1 : 0);
return $this;
}

public function enable_production(bool $enabled = true): self
{
$this->set_service_definition('build.args.PRODUCTION', $enabled ? 1 : 0);
Expand Down Expand Up @@ -93,6 +100,10 @@ public function __construct()
$this->enable_backup_tools();
}

if (env('ENABLE_BACKUP_TOOLS', '0') == '1') {
$this->enable_opcache();
}

if (!empty(env('PHP_VERSION'))) {
$this->set_version(env('PHP_VERSION'));
}
Expand Down
17 changes: 10 additions & 7 deletions app/Recipes/Laravel/LaravelRecipe.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public function customize_init(Command $parent_command, string $env_content): st
$php_version = $parent_command->ask("Enter PHP version", 'latest');
$this->set_env($env_content, "PHP_VERSION", $php_version);

if ($application_env === 'production') {
$enable_opcache = $parent_command->confirm("Should OpCache be enabled?");
$this->set_env($env_content, 'OPCACHE_ENABLED', $enable_opcache ? 1 : 0);
}


//<editor-fold desc="Network Configuration">
$parent_command->question("Network configuration");
Expand Down Expand Up @@ -253,8 +258,7 @@ public function build()
}



if(!empty(env('ENABLE_PULSE'))){
if (!empty(env('ENABLE_PULSE'))) {
$this->add_container(Pulse::class)
->add_network($this->internal_network())
->depends_on('mysql')
Expand Down Expand Up @@ -290,8 +294,7 @@ private function build_nginx(Php $php): Nginx
}
";

if(($cache_age = env('NGINX_CACHE_AGE')) && ($cache_files = env('NGINX_CACHE_FILES'))){

if (($cache_age = env('NGINX_CACHE_AGE')) && ($cache_files = env('NGINX_CACHE_FILES'))) {


$extra_site_config .= "
Expand Down Expand Up @@ -327,7 +330,7 @@ private function build_nginx(Php $php): Nginx
if (!empty(env('NGINX_PORT_SSL'))) {
$nginx->map_port(env('NGINX_PORT_SSL'), 443);
$this->add_exposed_host(env('HOST', self::DEFAULT_HOST));
$this->add_exposed_address(self::LABEL . " SSL", "https", env('HOST', self::DEFAULT_HOST), env('NGINX_PORT_SSL'));
$this->add_exposed_address(self::LABEL." SSL", "https", env('HOST', self::DEFAULT_HOST), env('NGINX_PORT_SSL'));
}

$proxy_network = env('REVERSE_PROXY_NETWORK');
Expand Down Expand Up @@ -418,7 +421,7 @@ public function build_phpmyadmin(MySql $mysql, Nginx $nginx): ?PhpMyAdmin
}

if (!empty(env("PHPMYADMIN_SUBDOMAIN"))) {
$host = env('PHPMYADMIN_SUBDOMAIN') . "." . env('HOST');
$host = env('PHPMYADMIN_SUBDOMAIN').".".env('HOST');
$nginx->add_proxy($host, 80, $phpmyadmin->service_name(), 80);
$this->add_exposed_host($host);
$this->add_exposed_address("PhpMyAdmin ", "http", $host, 80);
Expand Down Expand Up @@ -447,7 +450,7 @@ public function build_mailhog(Nginx $nginx): ?MailHog
}

if (!empty(env("MAILHOG_SUBDOMAIN"))) {
$host = env('MAILHOG_SUBDOMAIN') . "." . env('HOST');
$host = env('MAILHOG_SUBDOMAIN').".".env('HOST');
$nginx->add_proxy($host, 80, $mailhog->service_name(), 8025);
$this->add_exposed_host($host);
$this->add_exposed_address("MailHog ", "http", $host, 80);
Expand Down
1 change: 1 addition & 0 deletions storage/app/env/Laravel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ EXPOSE_INTERNAL_HOST=0
PHP_VERSION=latest
ENABLE_LIBREOFFICE_WRITER=0
ENABLE_BACKUP_TOOLS=0
ENABLE_OPCACHE=0


#######################
Expand Down

0 comments on commit 63c5356

Please sign in to comment.