Skip to content

Commit ded236f

Browse files
committed
Add healthcheck configuration to Dockerfile and Caddyfile for frankenphp variation
- Introduced a HEALTHCHECK command in the Dockerfile with specified parameters. - Updated Caddyfile to define healthcheck endpoints and log skipping for both default and custom healthcheck paths. - Enhanced full Caddyfile to redirect localhost healthcheck requests to HTTPS.
1 parent c465d9b commit ded236f

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/variations/frankenphp/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,7 @@ EXPOSE 8080 8443 8443/udp 2019
227227

228228
ENTRYPOINT ["docker-php-serversideup-entrypoint"]
229229

230-
CMD ["frankenphp", "run", "--config", "/etc/frankenphp/Caddyfile", "--adapter", "caddyfile"]
230+
CMD ["frankenphp", "run", "--config", "/etc/frankenphp/Caddyfile", "--adapter", "caddyfile"]
231+
232+
HEALTHCHECK --start-period=60s --start-interval=3s --interval=10s --timeout=3s --retries=3 \
233+
CMD [ "sh", "-c", "curl --insecure --silent --location --show-error --fail http://localhost:8080$HEALTHCHECK_PATH || exit 1" ]

src/variations/frankenphp/etc/frankenphp/Caddyfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,18 @@ fd00::/8 \
6363
# Match serversideup/php log levels to Caddy address log levels
6464
import log-level/address/{$LOG_OUTPUT_LEVEL:info}.caddyfile
6565

66-
# Healthcheck endpoint
67-
@health {
66+
# Define the Caddy healthcheck endpoint
67+
@caddy-healthcheck {
6868
path /healthcheck
6969
}
70-
respond @health "OK" 200
71-
log_skip @health
70+
respond @caddy-healthcheck "OK" 200
71+
log_skip @caddy-healthcheck
72+
73+
# Define the custom healthcheck endpoint
74+
@healthcheckpath {
75+
path {$HEALTHCHECK_PATH:/healthcheck}
76+
}
77+
log_skip @healthcheckpath
7278

7379
php_server {
7480
{$CADDY_PHP_SERVER_OPTIONS}

src/variations/frankenphp/etc/frankenphp/ssl-mode/full.caddyfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
{$CADDY_HTTP_SERVER_ADDRESS:http://} {
2+
# Redirect localhost healthcheck requests to HTTPS with the correct port
3+
@healthcheck {
4+
remote_ip 127.0.0.1/8 ::1
5+
path /healthcheck # Caddy healthcheck endpoint
6+
path {$HEALTHCHECK_PATH:/healthcheck} # Custom healthcheck endpoint
7+
}
8+
log_skip @healthcheck
9+
redir @healthcheck https://localhost:{$CADDY_HTTPS_PORT:8443}{uri} 308
10+
11+
# Redirect all other traffic to HTTPS (without explicit port)
212
redir https://{host}{uri} 308
313
}
414

0 commit comments

Comments
 (0)