Compare commits

...
16 Commits
Author SHA1 Message Date
Daniel 4e82961d5a Prepare pull-based Docker releases
Publish Docker image / build (push) Failing after 7s
2026-05-03 19:05:50 +02:00
Daniel 0bd2204857 Track demo Caddyfile ignore rule
Publish Docker image / build (push) Failing after 6s
2026-05-03 19:03:15 +02:00
Daniel 3eb00a68f1 Ignore local demo Caddyfile
Publish Docker image / build (push) Failing after 6s
2026-05-03 19:03:00 +02:00
Daniel 9e1464bd76 Restore KonCad host port mapping
Publish Docker image / build (push) Failing after 6s
2026-05-03 19:01:14 +02:00
Daniel e9035bf6fe Improve Caddyfile editor for demo-style configs
Publish Docker image / build (push) Failing after 6s
2026-05-03 18:59:32 +02:00
Daniel d672ad3f47 Stop tracking deploy script
Publish Docker image / build (push) Failing after 6s
2026-05-03 18:37:26 +02:00
Daniel 2a91ccc110 Remove compose port mapping and document network env
Publish Docker image / build (push) Failing after 39s
2026-05-03 18:34:38 +02:00
Daniel 8464c4fb4e remove Enable Admin API toggle
Publish Docker image / build (push) Failing after 3s
2026-04-07 13:57:49 +02:00
Daniel c88cd118be update README: CADDYFILE_IMPORT is always read, not just first boot
Publish Docker image / build (push) Failing after 3s
2026-04-07 13:21:01 +02:00
Daniel bd1eddbe62 fix undefined $auth_enabled after auth refactor
Publish Docker image / build (push) Failing after 3s
2026-04-07 13:07:45 +02:00
Daniel 994cca7d7e fix /data permissions — chown www-data in image
Publish Docker image / build (push) Failing after 3s
2026-04-07 13:04:06 +02:00
Daniel 123720d39a first-run setup form — create credentials via UI, stored in /data/.auth
Publish Docker image / build (push) Failing after 1m54s
2026-04-07 00:47:11 +02:00
Daniel e54fec540b add session auth + always read from import file on load
Publish Docker image / build (push) Has been cancelled
2026-04-07 00:41:57 +02:00
Daniel 14fc275da7 update README: use published image, add updating instructions
Publish Docker image / build (push) Has been cancelled
2026-04-06 23:35:17 +02:00
Daniel 34da40abd6 add gitea actions workflow to publish docker image
Publish Docker image / build (push) Has been cancelled
2026-04-06 23:34:59 +02:00
Daniel 2927040354 untrack .gitignore, ignore itself 2026-04-06 23:30:30 +02:00
10 changed files with 1240 additions and 151 deletions

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
.git
.claude
.superpowers
docs
caddy
deploy.sh
README.md
+37
View File
@@ -0,0 +1,37 @@
name: Publish Docker image
on:
push:
branches: [master]
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to Gitea registry
uses: docker/login-action@v3
with:
registry: git.d4nn13.de
username: ${{ gitea.actor }}
password: ${{ secrets.GITEA_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: git.d4nn13.de/d4nn13/koncad
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+4 -1
View File
@@ -1,2 +1,5 @@
caddy/Caddyfile
.gitignore
caddy/
deploy.sh
.superpowers/
Caddyfile_demo.txt
+2
View File
@@ -8,4 +8,6 @@ RUN docker-php-ext-enable curl 2>/dev/null || \
COPY app/ /var/www/html/
RUN mkdir -p /data && chown www-data:www-data /data
EXPOSE 80
+39 -10
View File
@@ -5,8 +5,8 @@ Web UI for managing an existing dockerized [Caddy](https://caddyserver.com/) ins
## Features
- **Structured editor** — separate panels for global options and each site block
- **Raw editor** — optional full Caddyfile editing escape hatch for advanced changes
- **Admin API check** — blocks editing if Caddy's admin API is unreachable on load
- **Admin API toggle** — one checkbox adds/removes `admin :2019` from global options
- **Upstream reachability check** — warns before deploy if any `reverse_proxy` target is unreachable, with option to deploy anyway
- **Atomic deploy** — posts config to Caddy's `/load` endpoint; bad configs are rejected without disrupting the running instance
@@ -18,29 +18,56 @@ Web UI for managing an existing dockerized [Caddy](https://caddyserver.com/) ins
## Setup
### 1. Clone and configure
### 1. Create a `docker-compose.yml`
```bash
git clone https://git.d4nn13.de/d4nn13/KonCad /opt/KonCad
```yaml
services:
koncad:
image: git.d4nn13.de/d4nn13/koncad:latest
restart: unless-stopped
volumes:
- koncad_data:/data
- /opt/caddy:/caddy:ro
environment:
# Caddy admin API reachable on the shared Docker network.
CADDY_ADMIN_URL: http://caddy:2019
# Read-only source Caddyfile from your existing Caddy setup.
CADDYFILE_IMPORT: /caddy/Caddyfile
networks:
# Join the same external Docker network as your Caddy container.
- caddy-network
volumes:
koncad_data:
networks:
caddy-network:
# Use the pre-existing network your Caddy container already uses.
external: true
```
Edit `docker-compose.yml` to match your environment:
Adjust to match your environment:
| Setting | Description |
|---|---|
| `CADDY_ADMIN_URL` | URL of Caddy's admin API — use the container name as hostname |
| `CADDYFILE_IMPORT` | Path to your existing Caddyfile (read-only, used once on first boot) |
| `CADDYFILE_IMPORT` | Path to your existing Caddyfile (read-only, always used as source of truth — external edits are reflected on every page load) |
| `- /opt/caddy:/caddy:ro` | Adjust to wherever your Caddy config directory lives |
| `caddy-network` | Replace with your existing Caddy Docker network name |
### 2. Start
```bash
cd /opt/KonCad
docker compose up -d --build
docker compose up -d
```
KonCad is available at `http://<host>:8080`.
### Updating
```bash
docker compose pull && docker compose up -d
```
Expose KonCad through your existing Caddy setup on the shared Docker network.
On first load it imports your existing Caddyfile (read-only). After the first deploy, KonCad manages its own copy.
@@ -49,9 +76,11 @@ On first load it imports your existing Caddyfile (read-only). After the first de
| Action | Description |
|--------|-------------|
| **Global Options** panel | Edit top-level Caddy options (email, logging, etc.) |
| **Enable Admin API** checkbox | Adds/removes `admin :2019` from global options |
| **Raw Caddyfile** mode | Edit the full Caddyfile directly; deploy still uses Caddy's admin API, so no restart is required |
| **+ Add Site** | Creates a new site block |
| **Remove** (per site) | Deletes that site block |
| **Deploy** | Validates and applies config via Caddy's `/load` API; shows errors inline if rejected |
If any `reverse_proxy` upstream is unreachable at deploy time, a warning modal lists them — you can cancel or deploy anyway.
Switching from raw mode back to structured mode reparses the file, so comments and exact formatting may be normalized.
+848 -59
View File
File diff suppressed because it is too large. Load diff
-80
View File
@@ -1,80 +0,0 @@
#!/usr/bin/env bash
# KonCad deployment script
# Credentials stored in: ~/.config/koncad/deploy.env
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG="$HOME/.config/koncad/deploy.env"
if [[ ! -f "$CONFIG" ]]; then
echo "ERROR: $CONFIG not found."
echo "Create it with:"
echo " mkdir -p ~/.config/koncad"
echo " cat > $CONFIG <<EOF"
echo " GITEA_TOKEN=your_token"
echo " GITEA_URL=https://git.d4nn13.de"
echo " GITEA_USER=d4nn13"
echo " GITEA_REPO=KonCad"
echo " DEPLOY_HOST=daniel@172.30.16.10"
echo " DEPLOY_PATH=/opt/KonCad"
echo " EOF"
echo " chmod 600 $CONFIG"
exit 1
fi
# shellcheck source=/dev/null
source "$CONFIG"
# ── Parse args ────────────────────────────────────────────────────────────────
DO_GIT=1
DO_SSH=1
MSG="${1:-}"
for arg in "$@"; do
case "$arg" in
--git-only) DO_SSH=0 ;;
--ssh-only) DO_GIT=0 ;;
--help|-h)
echo "Usage: ./deploy.sh [commit message] [--git-only] [--ssh-only]"
exit 0 ;;
esac
done
# ── Git commit + push ─────────────────────────────────────────────────────────
if [[ "$DO_GIT" -eq 1 ]]; then
cd "$SCRIPT_DIR"
# Set token in remote temporarily
git remote set-url origin "https://${GITEA_USER}:${GITEA_TOKEN}@${GITEA_URL#https://}/${GITEA_USER}/${GITEA_REPO}.git"
git add -A
if git diff --cached --quiet; then
echo "→ Git: nothing to commit"
else
COMMIT_MSG="${MSG:-deploy $(date '+%Y-%m-%d %H:%M')}"
git commit -m "$COMMIT_MSG"
echo "→ Git: committed — $COMMIT_MSG"
fi
git push origin master
echo "→ Git: pushed to ${GITEA_URL}/${GITEA_USER}/${GITEA_REPO}"
# Strip token from remote URL
git remote set-url origin "https://${GITEA_URL#https://}/${GITEA_USER}/${GITEA_REPO}.git"
fi
# ── rsync to server ───────────────────────────────────────────────────────────
if [[ "$DO_SSH" -eq 1 ]]; then
rsync -av --delete \
--exclude='.git' \
--exclude='.env' \
--exclude='.gitignore' \
--exclude='deploy.sh' \
--exclude='caddy/' \
--exclude='README.md' \
"$SCRIPT_DIR/" "${DEPLOY_HOST}:${DEPLOY_PATH}/"
echo "→ SSH: synced to ${DEPLOY_HOST}:${DEPLOY_PATH}"
fi
echo "✓ Done"
+5 -1
View File
@@ -1,7 +1,7 @@
services:
koncad:
build: .
image: git.d4nn13.de/d4nn13/koncad:latest
restart: unless-stopped
ports:
- "8080:80"
@@ -9,9 +9,12 @@ services:
- koncad_data:/data
- /opt/caddy:/caddy:ro
environment:
# Caddy admin API reachable on the shared Docker network.
CADDY_ADMIN_URL: http://caddy:2019
# Read-only source Caddyfile from your existing Caddy setup.
CADDYFILE_IMPORT: /caddy/Caddyfile
networks:
# Join the same external Docker network as your Caddy container.
- caddy-network
volumes:
@@ -19,4 +22,5 @@ volumes:
networks:
caddy-network:
# Use the pre-existing network your Caddy container already uses.
external: true
@@ -0,0 +1,34 @@
# Remote Deploy Debug Log
Date: 2026-05-03
Target: `daniel@172.30.16.10:/opt/KonCad`
## Summary
- The remote host was already running `koncad-koncad-1` on port `8080`.
- `/opt/KonCad` only contained deployment metadata (`Dockerfile`, `docker-compose.yml`, workflow files) and did not contain `app/`.
- The original deploy flow synced source files to `/opt/KonCad`, but `docker-compose.yml` used only the published image, so remote source changes were not applied unless the host rebuilt separately.
## Changes made
- Added `build: .` to `docker-compose.yml` so the server can build from the synced checkout.
- Updated `deploy.sh` to run `docker compose up -d --build` on the remote host after `rsync`.
- Added `--no-remote-restart` for cases where only file sync is wanted.
- Added `.dockerignore` and tightened `rsync` excludes so editor metadata and docs are not part of the deployment payload.
## Remote checks performed
- Confirmed container status with `docker ps`.
- Confirmed the live app answered on `http://127.0.0.1:8080/`.
- Confirmed the container mounts `/opt/caddy` read-only and persists `/data` in the `koncad_koncad_data` volume.
- Confirmed existing auth state is already present in `/data/.auth`.
- Rebuilt the container on the host with `docker compose up -d --build`.
- Verified `/opt/KonCad/app/index.php` and `/var/www/html/index.php` have the same SHA-256 hash after deploy.
- Verified `php -l /var/www/html/index.php` passes inside the running container.
- Verified KonCad can reach `http://caddy:2019/config/` from inside the container.
- Cleaned stale `.claude`, `.superpowers`, and `docs` directories from `/opt/KonCad` on the server.
## Notes
- Local PHP tooling was not available in this workspace (`php: command not found`), so syntax/runtime verification was done on the remote host.
- The Apache log still shows the harmless `Could not reliably determine the server's fully qualified domain name` startup warning from the base image.
@@ -0,0 +1,264 @@
<!-- Edited with Claude Code -->
# KonCad UI redesign — design
Refresh the KonCad web UI with a "Soft Slate" visual style (GitHub / Notion-dark
inspired), light/dark via `prefers-color-scheme`, lightweight inline syntax
highlighting for the Caddyfile editors, and a handful of small UX wins. No
backend changes; same single-file PHP structure.
## Goals
- A modern, calm, information-dense look that fits a homelab tool you open
occasionally.
- Auto-respect the OS color-scheme preference (no manual toggle).
- Make the Caddyfile editors readable at a glance with simple syntax colors.
- Add a small set of polish improvements that the new look invites — without
changing what the app does or its data flow.
## Non-goals
- No changes to PHP backend logic (parser, save handler, upstream check, auth
model).
- No new dependencies. Stays a single-file PHP tool — no CDN, no build step.
- No structural rework — header / global panel / list of sites stays.
- No new features (no draft staging, no diff view, no per-directive forms,
no bulk site operations, no manual theme toggle).
- No editor features beyond highlighting (no line numbers, no bracket matching,
no autocomplete).
## Visual system
CSS custom properties on `:root` for dark, overridden inside
`@media (prefers-color-scheme: light)`. Both auth screens and the main page
use the same token set.
| Token | Dark | Light | Used for |
|---|---|---|---|
| `--bg` | `#0d1117` | `#f6f8fa` | page background |
| `--surface` | `#161b22` | `#ffffff` | panels, cards |
| `--surface-2` | `#0d1117` | `#f6f8fa` | editor / nested surfaces |
| `--border` | `#21262d` | `#d0d7de` | every divider |
| `--text` | `#e6edf3` | `#1f2328` | primary text |
| `--muted` | `#7d8590` | `#656d76` | labels, subtle text |
| `--accent` | `#58a6ff` | `#0969da` | links, focus, addresses |
| `--accent-bg` | `rgba(88,166,255,0.12)` | `rgba(9,105,218,0.1)` | accent backgrounds, focus ring |
| `--ok` | `#3fb950` | `#1a7f37` | success status |
| `--warn` | `#d29922` | `#9a6700` | warnings |
| `--error` | `#f85149` | `#cf222e` | errors |
**Type:** Inter via system stack
(`-apple-system, "Segoe UI", "Inter", system-ui, sans-serif`); JetBrains Mono
for code (with monospace fallback). Sizes: 13px base, 12px secondary, 11px
labels/badges.
**Geometry:** 8px radius on inputs/buttons, 10px on panels. 1px borders
throughout — no drop shadows. Focus ring: `0 0 0 3px var(--accent-bg)` on
inputs and buttons. Spacing on a 4px grid.
## Layout
Same three regions as today.
### Header (sticky)
- Left: a small (18×18) gradient square logo mark + "KonCad" word in 700
weight, `-0.01em` letter-spacing.
- Center: a status pill — `● Caddy ready` (green) on success,
`● Caddy unreachable` (red) when the admin API is down, `● Deploying…`
(amber, with a 1.4s pulse animation) during a deploy. Pill background uses
a tinted version of its color.
- Right: primary `Deploy` button (green, GitHub-style primary) and a quiet
`Log out` ghost button when auth is enabled.
### Main column
- `max-width: 960px` centered, 1.5rem horizontal padding.
- **Global Options panel** — surface card with a header strip
(`Global Options` title + a small grey badge counting non-blank,
non-comment lines, e.g. `2 directives`). Body holds the highlighted editor.
- **Sites section** — section title `Sites` with a `+ Add site` ghost button on
the right, then a vertical list of site cards.
### Site card
- **Collapsed**: chevron, address (mono, `--accent` color), a one-line summary
chip (`→ host:port` if the body has a `reverse_proxy` line, else
`N directives`), and a `Remove` ghost-danger button visible on hover.
- **Expanded**: address bar, the highlighted editor, and any
`upstream-warnings` rendering area (existing slot, restyled).
### Empty state for sites
A dashed-border placeholder card replacing the current grey one-liner: small
icon (`⊕` or similar), heading `No sites yet`, and an inline primary
`+ Add site` button.
### Auth screens (setup / login)
Same centered-card pattern, retoned to the new tokens. Logo mark + "KonCad"
header, subtitle (`Create your login credentials` / `Sign in to continue`),
form with one username + one password input and a primary submit button.
Inline error message uses `--error`.
### Modals & toasts
- **Upstream warning modal**: same content, retoned. Dark-mode backdrop gets
`backdrop-filter: blur(4px)`.
- **Toasts**: same triggers, restyled. Slide in with
`transform: translateY(8px) → 0`, fade. Auto-dismiss at 5s (unchanged).
## Highlighted editor
Textarea-overlay technique. Native cursor, undo, IME, copy/paste behavior is
preserved; the highlighted layer is purely decorative.
### Markup per editor
```html
<div class="editor-wrap">
<pre class="editor-hl" aria-hidden="true"></pre>
<textarea class="editor-input" spellcheck="false">…</textarea>
</div>
```
### Mechanics
- `<pre>` and `<textarea>` are absolutely positioned in the same box, share
identical font, font-size, line-height, padding, border, and box-sizing.
- Textarea has `color: transparent; caret-color: var(--text)` so the user
sees the painted `<pre>` text and a real caret.
- On every `input` and `scroll`: read `textarea.value`, run `tokenize()`, write
`<pre>.innerHTML`, copy `scrollTop`/`scrollLeft` from textarea to `<pre>`.
- A trailing newline is appended before tokenizing so the last line renders.
### Tokenizer
Pure-JS, regex-based, ~60 LOC. Tokenization runs per-line, in this priority
order so earlier rules win:
1. Leading whitespace — preserved as-is.
2. Comment — `#` to end of line.
3. String — `"…"` and `'…'` (escape-aware: `\\` and `\"`).
4. Placeholder — `\{[^{}\n]*\}` matching `{$VAR}`, `{http.…}`, `{args.0}`,
etc. Bare `{` or `}` outside this pattern fall through to the brace rule.
5. Brace — lone `{` or `}`.
6. Number — `:\d+` (port-like) and standalone integers.
7. Directive — first non-whitespace word of the line, only if it's in the
known directive list.
8. Default — any other character class falls through to plain text.
Known directives (initial list): `reverse_proxy`, `root`, `file_server`,
`encode`, `tls`, `header`, `redir`, `respond`, `route`, `handle`,
`handle_path`, `import`, `log`, `email`, `admin`, `auto_https`, `php_fastcgi`,
`basicauth`, `try_files`, `rewrite`, `uri`, `request_body`, `templates`,
`map`, `metrics`, `acme_dns`, `acme_ca`. Easy to extend later by appending
to the list.
### Token classes & colors
| Class | Dark | Light |
|---|---|---|
| `c` comment | `#7d8590` | `#6e7781` |
| `d` directive | `#ff7b72` | `#cf222e` |
| `s` string | `#a5d6ff` | `#0a3069` |
| `p` placeholder | `#d2a8ff` | `#8250df` |
| `n` number | `#79c0ff` | `#0550ae` |
| `b` brace | `#7d8590` | `#6e7781` |
These live as CSS variables (`--tok-c`, `--tok-d`, …) under both the dark and
light blocks.
### Tab handling
Existing `handleTab()` behavior preserved (Tab inserts 4 spaces, no
focus-jump). The overlay re-tokenizes on the resulting `input` event.
### Scope
The two existing editor types — global options + each site body. Both render
through a single `mountEditor(textarea)` helper. No line numbers, no
bracket matching, no autocomplete.
## Small UX polish
- **Header status pill** wired to the existing `check_admin` result and to
deploy state.
- **Site card summary chip** (collapsed only): scan the body for the first
`reverse_proxy` line and show `→ host:port` (truncated to ~28 chars). If
none, show `N directives` (non-blank, non-comment lines). Updated on
every collapse and on `change` of the textarea.
- **Directive count badge** on the Global Options header: count of non-blank,
non-comment lines. Updated on `input`, debounced 200ms.
- **Remove site → 1-step inline confirm**: first click flips the button into
a red `Confirm remove?` for ~3 seconds; second click within that window
deletes. Click outside / 3s timeout reverts.
- **Deploy keyboard shortcut**: `Cmd/Ctrl+S` triggers `preDeploy()`. Listener
`preventDefault`s only when focus is inside the app (any element under
`<main>` or `<header>`), not globally — and only when the deploy button
is enabled. Button gets a `title` hint.
- **Disabled state** when admin API is unreachable: existing logic, plus a
visual change — disabled inputs get `0.5` opacity and a subtle striped
background (`repeating-linear-gradient`). The status pill shows the
reason text.
## Files touched
- **`app/index.php`** — only file modified.
### Sections being rewritten
- Auth-page HTML + `<style>` (currently lines ~239–275): retoned to the new
tokens, same form fields and POST behavior.
- Main page `<style>` block (currently lines ~282–550): replaced.
- Main page HTML (currently lines ~552–600): minor structural tweaks for the
status pill, summary chip, badge, empty state.
- `<script>` (currently lines ~602–886): adds `mountEditor()`, `tokenize()`,
`summaryFor()`, `directiveCount()`, `armRemove()`, and a global
keyboard-shortcut listener. Updates `renderSites()` to emit the new
markup. All other functions unchanged.
### Untouched
- All PHP above the auth-page HTML (config, session/auth, helpers, parser,
`caddyLoad`, `checkUpstream`, every `?action=…` handler).
- Existing JS: `init()`, `preDeploy()`, `doDeploy()`, `extractUpstreams()`,
`collectSites()`, `addSite()`, `removeSite()` core, `togglePanel()`,
`toggleSite()`, `setEditable()`, `setStatus()`, `setDeployBtn()`,
`toast()`, `esc()`, `logout()`, `handleTab()`. All keep their current
signatures and behavior.
## Risks & mitigations
- **Overlay desync** (highlighted layer drifting from textarea on paste, IME,
resize, or scroll): the textarea remains the source of truth; the `<pre>`
is rebuilt from `textarea.value` on every `input` and `scroll`. Identical
font metrics + a trailing-newline trick handle the last-line case.
- **`removeSite` two-click** is a behavior change. Acceptable: deleting a
configured site has a real blast radius, and a 3s armed window is friction
light.
- **Global `Cmd/Ctrl+S` capture** could surprise users in a textarea. Mitigated
by only `preventDefault`ing when the deploy button is enabled and focus is
inside the app shell.
- **Light-mode regression**: every color must come from a token — no hex
literals in component CSS. Manual test: flip OS theme and confirm both
palettes render correctly on every screen (auth, main, modal, toast,
disabled state).
## Manual test plan
1. Load with the existing Caddyfile — global + sites populate correctly,
highlighting renders for both editors.
2. Edit each editor — highlight tracks input, scroll syncs, Tab indents
without focus loss, paste of multi-line content highlights correctly.
3. Flip OS theme dark↔light — every screen (auth, main, modal, toast,
disabled state) re-themes without a reload.
4. Add site, remove site (verify 2-click confirm), collapse/expand cards,
summary chip updates after edits.
5. Deploy success → green pill + green toast. Deploy with bad config → red
pill + error toast with Caddy's message.
6. Stop the Caddy admin API → reload page → unreachable disabled state
renders, deploy button disabled, status pill red with reason.
7. `Cmd/Ctrl+S` triggers deploy when admin is reachable; does nothing when
disabled.
8. Setup screen (scratch container with `/data/.auth` removed) and login
screen both look right in both color schemes.