bootstrap from existing caddyfile on first load via read-only mount
This commit is contained in:
1 parent
a80433c9df
commit
61dd1c7a41
2 files changed
+11
-1
No files matched your search
+9
-1
@@ -2,6 +2,7 @@
|
|||||||
// ─── 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;
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user