Skip to content
Merged
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
583 changes: 503 additions & 80 deletions .github/workflows/ci-cd.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 8.1-nginx-prod/default.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ server {
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
{{ end }}
root {{ .Env.NGINX_ROOT }};
Expand Down
2 changes: 1 addition & 1 deletion 8.1-nginx/default.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ server {
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
{{ end }}
root {{ .Env.NGINX_ROOT }};
Expand Down
2 changes: 1 addition & 1 deletion 8.2-nginx-prod/default.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ server {
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
{{ end }}
root {{ .Env.NGINX_ROOT }};
Expand Down
2 changes: 1 addition & 1 deletion 8.2-nginx/default.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ server {
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
{{ end }}
root {{ .Env.NGINX_ROOT }};
Expand Down
2 changes: 1 addition & 1 deletion 8.3-nginx-prod/default.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ server {
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
{{ end }}
root {{ .Env.NGINX_ROOT }};
Expand Down
2 changes: 1 addition & 1 deletion 8.3-nginx/default.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ server {
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
{{ end }}
root {{ .Env.NGINX_ROOT }};
Expand Down
62 changes: 62 additions & 0 deletions 8.4-debian-nginx-prod/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
FROM debian:bookworm AS cert

WORKDIR /kool/ssl

RUN apt-get update && \
apt-get install -y openssl && \
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 && \
openssl rsa -passin pass:x -in server.pass.key -out _.localhost.key && \
rm server.pass.key && \
openssl req -new -key _.localhost.key -out server.csr \
-subj "/C=XX/ST=XX/L=XX/O=Kool-Local/OU=Localhost/CN=*.localhost" && \
openssl x509 -req -days 365 -in server.csr -signkey _.localhost.key -out _.localhost.crt && \
openssl x509 -in _.localhost.crt -out _.localhost.pem

FROM kooldev/php:8.4-debian-prod

ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
NGINX_LISTEN=80 \
NGINX_HTTPS=false \
NGINX_LISTEN_HTTPS=443 \
NGINX_HTTPS_CERT=/kool/ssl/_.localhost.pem \
NGINX_HTTPS_CERT_KEY=/kool/ssl/_.localhost.key \
NGINX_ROOT=/app/public \
NGINX_INDEX=index.php \
NGINX_CLIENT_MAX_BODY_SIZE=25M \
NGINX_PHP_FPM=unix:/run/php-fpm.sock \
NGINX_FASTCGI_READ_TIMEOUT=60s \
NGINX_FASTCGI_BUFFERS='8 8k' \
NGINX_FASTCGI_BUFFER_SIZE='16k' \
NGINX_ENTRYPOINT_WORKER_PROCESSES_AUTOTUNE=true

RUN apt-get update && apt-get install -y --no-install-recommends supervisor nginx wget \
&& chown -R kool:kool /var/lib/nginx \
&& chmod 770 /var/lib/nginx \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log \
# add h5bp/server-configs-nginx
&& mkdir -p /etc/nginx/conf.d \
&& mkdir /etc/nginx/h5bp \
&& cd /etc/nginx/h5bp \
&& wget https://github.com/h5bp/server-configs-nginx/archive/refs/tags/5.0.1.tar.gz -O h5bp.tgz \
&& tar xzvf h5bp.tgz \
Comment on lines +41 to +42
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commands pull Nginx configuration files from a third-party GitHub repository using wget and extract them without integrity verification. A compromised or malicious archive could alter the bundled Nginx configuration in unsafe ways in this production image. Use a pinned, trusted artifact and verify its checksum or signature before unpacking.

Copilot uses AI. Check for mistakes.
&& rm -f h5bp.tgz \
&& mv server-configs-nginx-*/h5bp/* . \
&& mv server-configs-nginx-*/nginx.conf /etc/nginx/nginx.conf \
&& sed -i "s|^user .*|user\ kool kool;|g" /etc/nginx/nginx.conf \
&& mv server-configs-nginx-*/mime.types /etc/nginx/mime.types \
&& rm -rf server-configs-nginx-* \
&& curl -L https://raw.githubusercontent.com/nginxinc/docker-nginx/master/entrypoint/30-tune-worker-processes.sh -o /kool/30-tune-worker-processes.sh \
&& chmod +x /kool/30-tune-worker-processes.sh \
&& apt-get purge -y --auto-remove wget \
&& rm -rf /var/lib/apt/lists/*

COPY supervisor.conf /kool/supervisor.conf
COPY default.tmpl /kool/default.tmpl
COPY entrypoint /kool/entrypoint
COPY --from=cert /kool/ssl /kool/ssl
RUN chmod +x /kool/entrypoint

EXPOSE 80

CMD [ "supervisord", "-c", "/kool/supervisor.conf" ]
50 changes: 50 additions & 0 deletions 8.4-debian-nginx-prod/default.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
server {
listen {{ .Env.NGINX_LISTEN }} default_server;
server_name _;
{{ if isTrue .Env.NGINX_HTTPS }}
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
{{ end }}
root {{ .Env.NGINX_ROOT }};
index {{ .Env.NGINX_INDEX }};
charset utf-8;

location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; }

client_max_body_size {{ .Env.NGINX_CLIENT_MAX_BODY_SIZE }};

error_page 404 /index.php;

location / {
try_files $uri /{{ .Env.NGINX_INDEX }}?$query_string;
}

location ~ \.php$ {
fastcgi_buffers {{ .Env.NGINX_FASTCGI_BUFFERS }};
fastcgi_buffer_size {{ .Env.NGINX_FASTCGI_BUFFER_SIZE }};
fastcgi_pass {{ .Env.NGINX_PHP_FPM }};
fastcgi_read_timeout {{ .Env.NGINX_FASTCGI_READ_TIMEOUT }};
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}

location ~ /\.ht {
deny all;
}

# good practices
add_header X-Frame-Options "SAMEORIGIN";

# basic H5BP suggestions
include h5bp/security/referrer-policy.conf;
include h5bp/security/x-content-type-options.conf;
include h5bp/cross-origin/requests.conf;

# performance enhancements (mostly for caching static data)
include h5bp/web_performance/cache-file-descriptors.conf;
include h5bp/web_performance/compression.conf;
}
25 changes: 25 additions & 0 deletions 8.4-debian-nginx-prod/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -e


# Run as current user
CURRENT_USER=${ASUSER:-${UID:-0}}

if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then
usermod -u $CURRENT_USER kool
fi

dockerize -template /kool/kool.tmpl:/usr/local/etc/php/conf.d/kool.ini -template /kool/zz-docker.tmpl:/usr/local/etc/php-fpm.d/zz-docker.conf -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf

/kool/30-tune-worker-processes.sh

# Run entrypoint if provided
if [ ! -z "$ENTRYPOINT" ] && [ -f "$ENTRYPOINT" ]; then
bash $ENTRYPOINT
fi

if [ "$1" = "sh" ] || [ "$1" = "bash" ] || [ "$1" = "php-fpm" ] || [ "$1" = "nginx" ] || [ "$1" = "supervisord" ]; then
exec "$@"
else
exec gosu kool "$@"
fi
27 changes: 27 additions & 0 deletions 8.4-debian-nginx-prod/supervisor.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[supervisord]
logfile=/dev/stdout
logfile_maxbytes=0
pidfile=/run/supervisord.pid
nodaemon=true

[program:php-fpm]
command = php-fpm
priority = 10
autorestart = true
stopasgroup = true
killasgroup = true
stderr_logfile = /dev/stderr
stdout_logfile = /dev/stdout
stderr_logfile_maxbytes = 0
stdout_logfile_maxbytes = 0

[program:nginx]
command = nginx -g "daemon off;"
priority = 20
autorestart = true
stopasgroup = true
killasgroup = true
stderr_logfile = /dev/stderr
stdout_logfile = /dev/stdout
stderr_logfile_maxbytes = 0
stdout_logfile_maxbytes = 0
62 changes: 62 additions & 0 deletions 8.4-debian-nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
FROM debian:bookworm AS cert

WORKDIR /kool/ssl

RUN apt-get update && \
apt-get install -y openssl && \
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048 && \
openssl rsa -passin pass:x -in server.pass.key -out _.localhost.key && \
rm server.pass.key && \
openssl req -new -key _.localhost.key -out server.csr \
-subj "/C=XX/ST=XX/L=XX/O=Kool-Local/OU=Localhost/CN=*.localhost" && \
openssl x509 -req -days 365 -in server.csr -signkey _.localhost.key -out _.localhost.crt && \
openssl x509 -in _.localhost.crt -out _.localhost.pem

FROM kooldev/php:8.4-debian

ENV PHP_FPM_LISTEN=/run/php-fpm.sock \
NGINX_LISTEN=80 \
NGINX_HTTPS=false \
NGINX_LISTEN_HTTPS=443 \
NGINX_HTTPS_CERT=/kool/ssl/_.localhost.pem \
NGINX_HTTPS_CERT_KEY=/kool/ssl/_.localhost.key \
NGINX_ROOT=/app/public \
NGINX_INDEX=index.php \
NGINX_CLIENT_MAX_BODY_SIZE=25M \
NGINX_PHP_FPM=unix:/run/php-fpm.sock \
NGINX_FASTCGI_READ_TIMEOUT=60s \
NGINX_FASTCGI_BUFFERS='8 8k' \
NGINX_FASTCGI_BUFFER_SIZE='16k' \
NGINX_ENTRYPOINT_WORKER_PROCESSES_AUTOTUNE=true

RUN apt-get update && apt-get install -y --no-install-recommends supervisor nginx wget \
&& chown -R kool:kool /var/lib/nginx \
&& chmod 770 /var/lib/nginx \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log \
# add h5bp/server-configs-nginx
&& mkdir -p /etc/nginx/conf.d \
&& mkdir /etc/nginx/h5bp \
&& cd /etc/nginx/h5bp \
&& wget https://github.com/h5bp/server-configs-nginx/archive/refs/tags/5.0.1.tar.gz -O h5bp.tgz \
&& tar xzvf h5bp.tgz \
Comment on lines +41 to +42
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commands download Nginx configuration files from a third-party GitHub repository using wget and immediately extract them without verifying integrity. If the archive is tampered with, it could introduce malicious or insecure Nginx configuration into the built image. Download from a pinned, trusted artifact and verify a checksum or signature before extraction.

Copilot uses AI. Check for mistakes.
&& rm -f h5bp.tgz \
&& mv server-configs-nginx-*/h5bp/* . \
&& mv server-configs-nginx-*/nginx.conf /etc/nginx/nginx.conf \
&& sed -i "s|^user .*|user\ kool kool;|g" /etc/nginx/nginx.conf \
&& mv server-configs-nginx-*/mime.types /etc/nginx/mime.types \
&& rm -rf server-configs-nginx-* \
&& curl -L https://raw.githubusercontent.com/nginxinc/docker-nginx/master/entrypoint/30-tune-worker-processes.sh -o /kool/30-tune-worker-processes.sh \
&& chmod +x /kool/30-tune-worker-processes.sh \
&& apt-get purge -y --auto-remove wget \
&& rm -rf /var/lib/apt/lists/*

COPY supervisor.conf /kool/supervisor.conf
COPY default.tmpl /kool/default.tmpl
COPY entrypoint /kool/entrypoint
COPY --from=cert /kool/ssl /kool/ssl
RUN chmod +x /kool/entrypoint

EXPOSE 80

CMD [ "supervisord", "-c", "/kool/supervisor.conf" ]
50 changes: 50 additions & 0 deletions 8.4-debian-nginx/default.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
server {
listen {{ .Env.NGINX_LISTEN }} default_server;
server_name _;
{{ if isTrue .Env.NGINX_HTTPS }}
listen {{ .Env.NGINX_LISTEN_HTTPS }} ssl http2;
ssl_certificate {{ .Env.NGINX_HTTPS_CERT }};
ssl_certificate_key {{ .Env.NGINX_HTTPS_CERT_KEY }};
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
{{ end }}
root {{ .Env.NGINX_ROOT }};
index {{ .Env.NGINX_INDEX }};
charset utf-8;

location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; }

client_max_body_size {{ .Env.NGINX_CLIENT_MAX_BODY_SIZE }};

error_page 404 /index.php;

location / {
try_files $uri /{{ .Env.NGINX_INDEX }}?$query_string;
}

location ~ \.php$ {
fastcgi_buffers {{ .Env.NGINX_FASTCGI_BUFFERS }};
fastcgi_buffer_size {{ .Env.NGINX_FASTCGI_BUFFER_SIZE }};
fastcgi_pass {{ .Env.NGINX_PHP_FPM }};
fastcgi_read_timeout {{ .Env.NGINX_FASTCGI_READ_TIMEOUT }};
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}

location ~ /\.ht {
deny all;
}

# good practices
add_header X-Frame-Options "SAMEORIGIN";

# basic H5BP suggestions
include h5bp/security/referrer-policy.conf;
include h5bp/security/x-content-type-options.conf;
include h5bp/cross-origin/requests.conf;

# performance enhancements (mostly for caching static data)
include h5bp/web_performance/cache-file-descriptors.conf;
include h5bp/web_performance/compression.conf;
}
31 changes: 31 additions & 0 deletions 8.4-debian-nginx/entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
set -e

if [ "$ENABLE_XDEBUG" = "true" ]; then
if ! docker-php-ext-enable xdebug >> /dev/null 2>&1; then
echo "[ERROR] An error happened enabling xdebug"
exit 1
fi
fi

# Run as current user
CURRENT_USER=${ASUSER:-${UID:-0}}

if [ ! -z "$CURRENT_USER" ] && [ "$CURRENT_USER" != "0" ]; then
usermod -u $CURRENT_USER kool
fi

dockerize -template /kool/kool.tmpl:/usr/local/etc/php/conf.d/kool.ini -template /kool/zz-docker.tmpl:/usr/local/etc/php-fpm.d/zz-docker.conf -template /kool/default.tmpl:/etc/nginx/conf.d/default.conf

/kool/30-tune-worker-processes.sh

# Run entrypoint if provided
if [ ! -z "$ENTRYPOINT" ] && [ -f "$ENTRYPOINT" ]; then
bash $ENTRYPOINT
fi

if [ "$1" = "sh" ] || [ "$1" = "bash" ] || [ "$1" = "php-fpm" ] || [ "$1" = "nginx" ] || [ "$1" = "supervisord" ]; then
exec "$@"
else
exec gosu kool "$@"
fi
27 changes: 27 additions & 0 deletions 8.4-debian-nginx/supervisor.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[supervisord]
logfile=/dev/stdout
logfile_maxbytes=0
pidfile=/run/supervisord.pid
nodaemon=true

[program:php-fpm]
command = php-fpm
priority = 10
autorestart = true
stopasgroup = true
killasgroup = true
stderr_logfile = /dev/stderr
stdout_logfile = /dev/stdout
stderr_logfile_maxbytes = 0
stdout_logfile_maxbytes = 0

[program:nginx]
command = nginx -g "daemon off;"
priority = 20
autorestart = true
stopasgroup = true
killasgroup = true
stderr_logfile = /dev/stderr
stdout_logfile = /dev/stdout
stderr_logfile_maxbytes = 0
stdout_logfile_maxbytes = 0
Loading