Add Apache support to Drupal

This commit is contained in:
Oliver Davies 2024-04-04 19:09:53 +01:00
parent 2f6673d941
commit 3065597f64
7 changed files with 34 additions and 4 deletions

View file

@ -11,8 +11,8 @@ build:
composer dump-env prod composer dump-env prod
./build-configs cache:clear ./bin/build-configs cache:clear
./build-configs cache:warmup ./bin/build-configs cache:warmup
# Generate the phar file. # Generate the phar file.
box compile --config box.json.dist box compile --config box.json.dist

View file

@ -113,6 +113,14 @@ final class CreateListOfFilesToGenerate
path: 'tools/docker/images/php/root/usr/local/etc/php', path: 'tools/docker/images/php/root/usr/local/etc/php',
)); ));
if (static::isApache(Arr::get($configurationData, 'web.type'))) {
$filesToGenerate[] = new TemplateFile(
data: 'php/drupal/apache/000-default.conf',
name: '000-default.conf',
path: 'tools/docker/images/php/root/etc/apache2/sites-available',
);
}
if (static::isCaddy(Arr::get($configurationData, 'web.type'))) { if (static::isCaddy(Arr::get($configurationData, 'web.type'))) {
$filesToGenerate[] = new TemplateFile( $filesToGenerate[] = new TemplateFile(
data: 'php/drupal/caddy/Caddyfile', data: 'php/drupal/caddy/Caddyfile',
@ -170,6 +178,15 @@ final class CreateListOfFilesToGenerate
return $next([$configurationData, $configDto, $filesToGenerate]); return $next([$configurationData, $configDto, $filesToGenerate]);
} }
private static function isApache(?string $webServer): bool
{
if (is_null($webServer)) {
return false;
}
return $webServer === WebServer::Apache->value;
}
private static function isCaddy(?string $webServer): bool private static function isCaddy(?string $webServer): bool
{ {
if (is_null($webServer)) { if (is_null($webServer)) {

View file

@ -251,7 +251,7 @@ final class ConfigDto
#[Assert\Collection([ #[Assert\Collection([
'type' => new Assert\Required([ 'type' => new Assert\Required([
new Assert\Choice(choices: ['nginx', 'caddy']), new Assert\Choice(choices: ['apache', 'caddy', 'nginx']),
]), ]),
])] ])]
public array $web; public array $web;

View file

@ -6,6 +6,7 @@ namespace App\Enum;
enum WebServer: string enum WebServer: string
{ {
case Apache = 'apache';
case Caddy = 'caddy'; case Caddy = 'caddy';
case Nginx = 'nginx'; case Nginx = 'nginx';
} }

View file

@ -65,7 +65,11 @@ RUN {{ command }}
COPY --chown=app:app tools/docker/images/php/root / COPY --chown=app:app tools/docker/images/php/root /
ENTRYPOINT ["/usr/local/bin/docker-entrypoint-php"] ENTRYPOINT ["/usr/local/bin/docker-entrypoint-php"]
{% if web.type == "apache" %}
CMD ["apache2-foreground"]
{% else %}
CMD ["php-fpm"] CMD ["php-fpm"]
{% endif %}
{% if dockerfile.stages.test %} {% if dockerfile.stages.test %}
################################################################################ ################################################################################

View file

@ -0,0 +1,8 @@
# {{ managedText|raw }}
<VirtualHost *:80>
DocumentRoot /var/www/html/{{ drupal.docroot }}
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

View file

@ -3100,5 +3100,5 @@
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": [],
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.3.0" "plugin-api-version": "2.6.0"
} }