Skip to content

Commit

Permalink
move conf
Browse files Browse the repository at this point in the history
  • Loading branch information
batonac committed Sep 17, 2024
1 parent 0f8edd7 commit 694d70a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 25 deletions.
File renamed without changes.
File renamed without changes.
13 changes: 9 additions & 4 deletions www.conf → conf/php-fpm.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
[global]
pid = /run/php-fpm.pid
error_log = /dev/stderr
daemonize = no

[www]
user = nobody
group = nobody
user = 0
group = 0
listen = /run/php-fpm.sock
listen.owner = nobody
listen.group = nobody
listen.owner = 0
listen.group = 0
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/sh
set -e

php-fpm &

# set shell as /bin/sh
# export SHELL=/bin/sh
# export WP_CLI_CUSTOM_SHELL=/bin/sh
Expand Down Expand Up @@ -97,4 +95,6 @@ cp -r /mu-plugins /var/www/html/wp-content/mu-plugins
chmod 755 /var/www/html/wp-content/mu-plugins

# Execute the main command
php-fpm --fpm-config /etc/php-fpm.conf &

exec "$@"
6 changes: 0 additions & 6 deletions php-fpm.conf

This file was deleted.

32 changes: 19 additions & 13 deletions wordpress.nix
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ let
opcache.interned_strings_buffer = 8
opcache.validate_timestamps = 1
opcache.revalidate_freq = 2
opcache.fast_shutdown = 1
opcache.enable_cli = 0
; enable just-in-time compilation
opcache.jit = 1
opcache.jit_buffer_size = 64M
; Error handling
error_reporting = E_ERROR | E_WARNING | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING | E_RECOVERABLE_ERROR
Expand Down Expand Up @@ -119,6 +125,15 @@ let
php = phpBuild;
});

start-server = pkgs.writeScriptBin "start-server" ''
#!${pkgs.runtimeShell}
# Start PHP-FPM
${phpBuild}/bin/php-fpm -R --fpm-config ${./conf/php-fpm.conf} &
# Start Caddy
${pkgs.lib.getExe pkgs.caddy} run --config ${./conf/Caddyfile}
'';

in
pkgs.dockerTools.buildLayeredImage {
name = imageName;
Expand All @@ -141,7 +156,7 @@ pkgs.dockerTools.buildLayeredImage {

config = {
Entrypoint = [ "${pkgs.lib.getExe pkgs.bashInteractive}" "/docker-entrypoint.sh" ];
Cmd = [ "${pkgs.lib.getExe pkgs.caddy}" "run" "--config" "/etc/caddy/Caddyfile" ];
Cmd = [ "start-server" ];
ExposedPorts = {
"80/tcp" = { };
};
Expand Down Expand Up @@ -169,10 +184,6 @@ pkgs.dockerTools.buildLayeredImage {
mkdir -p tmp
chmod 1777 tmp
# copy Caddyfile
mkdir -p etc/caddy
cp ${./Caddyfile} etc/caddy/Caddyfile
# enable Caddy logging
mkdir -p var/log/caddy
touch var/log/caddy/access.log
Expand All @@ -181,7 +192,7 @@ pkgs.dockerTools.buildLayeredImage {
# Copy WordPress files
mkdir -p var/www/html
cp ${./wp-config.php} wp-config.php
cp ${./conf/wp-config.php} wp-config.php
cp ${./docker-entrypoint.sh} docker-entrypoint.sh
chmod +x docker-entrypoint.sh
Expand All @@ -194,11 +205,6 @@ pkgs.dockerTools.buildLayeredImage {
# Set up PHP-FPM socket directory
mkdir -p run
chmod 755 run
# Create PHP-FPM configuration
mkdir -p etc/php-fpm.d
cp ${./php-fpm.conf} etc/php-fpm.conf
cp ${./www.conf} etc/php-fpm.d/www.conf
chmod 777 run
'';
}
}

0 comments on commit 694d70a

Please sign in to comment.