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
+13 -3

No files matched your search

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