bootstrap from existing caddyfile on first load via read-only mount

This commit is contained in:
Daniel committed 2026-04-06 23:07:50 +02:00
1 parent a80433c9df
commit 61dd1c7a41
2 files changed
+11 -1

No files matched your search

+9 -1
View File
@@ -2,6 +2,7 @@
// ─── Config ──────────────────────────────────────────────────────────────────
define('CADDY_ADMIN_URL', getenv('CADDY_ADMIN_URL') ?: 'http://localhost:2019');
define('CADDYFILE_STORE', getenv('CADDYFILE_STORE') ?: '/data/Caddyfile');
define('CADDYFILE_IMPORT', getenv('CADDYFILE_IMPORT') ?: '');
// ─── Helpers ─────────────────────────────────────────────────────────────────
function parseCaddyfile(string $content): array {
@@ -102,7 +103,14 @@ if (isset($_GET['action'])) {
exit;
case 'load':
$raw = file_exists(CADDYFILE_STORE) ? file_get_contents(CADDYFILE_STORE) : '';
if (file_exists(CADDYFILE_STORE)) {
$raw = file_get_contents(CADDYFILE_STORE);
} elseif (CADDYFILE_IMPORT && file_exists(CADDYFILE_IMPORT)) {
$raw = file_get_contents(CADDYFILE_IMPORT);
file_put_contents(CADDYFILE_STORE, $raw);
} else {
$raw = '';
}
echo json_encode(['ok' => true, 'data' => parseCaddyfile($raw)]);
exit;
+2
View File
@@ -7,8 +7,10 @@ services:
- "8080:80"
volumes:
- koncad_data:/data
- /opt/caddy:/caddy:ro
environment:
CADDY_ADMIN_URL: http://caddy:2019
CADDYFILE_IMPORT: /caddy/Caddyfile
networks:
- caddy-network