mirror of
https://github.com/opdavies/build-configs.git
synced 2025-02-02 13:57:33 +00:00
feat: add Caddy as a web server
This commit is contained in:
parent
1d7f796538
commit
eb29d11134
|
@ -127,9 +127,14 @@ final class BuildConfigurationCommand extends Command
|
|||
$this->filesToGenerate->push(['php/docker-entrypoint-php', 'tools/docker/images/php/root/usr/local/bin/docker-entrypoint-php']);
|
||||
}
|
||||
|
||||
if (self::isCaddy(Arr::get($configurationData, 'web.type'))) {
|
||||
$this->filesystem->mkdir("{$this->outputDir}/tools/docker/images/web/root/etc/caddy");
|
||||
$this->filesToGenerate->push(['web/caddy/Caddyfile', 'tools/docker/images/web/root/etc/caddy/Caddyfile']);
|
||||
}
|
||||
|
||||
if (self::isNginx(Arr::get($configurationData, 'web.type'))) {
|
||||
$this->filesystem->mkdir("{$this->outputDir}/tools/docker/images/nginx/root/etc/nginx/conf.d");
|
||||
$this->filesToGenerate->push(['default.conf', 'tools/docker/images/nginx/root/etc/nginx/conf.d/default.conf']);
|
||||
$this->filesystem->mkdir("{$this->outputDir}/tools/docker/images/web/root/etc/nginx/conf.d");
|
||||
$this->filesToGenerate->push(['web/nginx/default.conf', 'tools/docker/images/web/root/etc/nginx/conf.d/default.conf']);
|
||||
}
|
||||
|
||||
$this->generateFiles($configurationData);
|
||||
|
@ -157,6 +162,15 @@ final class BuildConfigurationCommand extends Command
|
|||
}
|
||||
}
|
||||
|
||||
private static function isCaddy(?string $webServer): bool
|
||||
{
|
||||
if (is_null($webServer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return strtoupper($webServer) === WebServer::CADDY->name;
|
||||
}
|
||||
|
||||
private static function isNginx(?string $webServer): bool
|
||||
{
|
||||
if (is_null($webServer)) {
|
||||
|
|
|
@ -6,5 +6,6 @@ namespace OliverDaviesLtd\BuildConfigs\Enum;
|
|||
|
||||
enum WebServer
|
||||
{
|
||||
case CADDY;
|
||||
case NGINX;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,17 @@ RUN {% for command in dockerfile.stages.test.commands -%}
|
|||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if web.type == "caddy" %}
|
||||
################################################################################
|
||||
|
||||
FROM caddy:2 as web
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY tools/docker/images/web/root /
|
||||
{% endif %}
|
||||
|
||||
{% if web.type == "nginx" %}
|
||||
################################################################################
|
||||
|
||||
|
@ -62,5 +73,5 @@ EXPOSE 8080
|
|||
|
||||
WORKDIR /app
|
||||
|
||||
COPY tools/docker/images/nginx/root /
|
||||
COPY tools/docker/images/web/root /
|
||||
{% endif %}
|
||||
|
|
4
templates/web/caddy/Caddyfile.twig
Normal file
4
templates/web/caddy/Caddyfile.twig
Normal file
|
@ -0,0 +1,4 @@
|
|||
:80
|
||||
root * /app/docroot
|
||||
file_server
|
||||
php_fastcgi php:9000
|
20
templates/web/nginx/default.conf.twig
Normal file
20
templates/web/nginx/default.conf.twig
Normal file
|
@ -0,0 +1,20 @@
|
|||
server {
|
||||
server_name _;
|
||||
|
||||
root /app/docroot;
|
||||
|
||||
location / {
|
||||
try_files $uri /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
|
||||
try_files $fastcgi_script_name =404;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param QUERY_STRING $query_string;
|
||||
fastcgi_intercept_errors on;
|
||||
fastcgi_pass php:9000;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue