Skip to content

Commit 5e580d2

Browse files
author
Chris Funderburg
committed
feat(docker): include built-in documentation and templates for seeding
1 parent 8ef1d2a commit 5e580d2

5 files changed

Lines changed: 99 additions & 31 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dist/
1313
*.md
1414
!README.md
1515
!data/templates/**
16+
!data/Codex Documentation/README.md
1617
.env*
1718
.DS_Store
1819
*.log

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ COPY --from=builder /app/client/dist ./client/dist
4646
# Include default templates in the image for first-run seeding into the mounted data volume
4747
COPY data/templates ./seed/templates
4848

49+
# Include built-in documentation that should always be synced into the mounted data volume
50+
COPY ["data/Codex Documentation/README.md", "./seed/docs/Codex Documentation/README.md"]
51+
4952
# Create data directory and set permissions
5053
RUN mkdir -p /app/data && chown -R codex:codex /app
5154

@@ -64,6 +67,10 @@ ENV DATA_DIR=/app/data
6467
ENV CODEX_SEED_TEMPLATES=true
6568
ENV CODEX_SEED_TEMPLATES_DIR=/app/seed/templates
6669

70+
# Always sync built-in documentation README into the data volume on startup
71+
ENV CODEX_SYNC_BUILTIN_DOCS=true
72+
ENV CODEX_SYNC_BUILTIN_DOCS_DIR=/app/seed/docs
73+
6774
# Health check
6875
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
6976
CMD wget --no-verbose --tries=1 --spider http://localhost:3001/api || exit 1

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
[![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue)](https://www.typescriptlang.org/)
1010
[![React](https://img.shields.io/badge/React-19-61dafb)](https://reactjs.org/)
11-
[![Express](https://img.shields.io/badge/Express-4.18-green)](https://expressjs.com/)
11+
[![Express](https://img.shields.io/badge/Express-5.2.1-green)](https://expressjs.com/)
1212

1313
## ✨ Features
1414

@@ -378,7 +378,7 @@ Then open [http://localhost:3000](http://localhost:3000) in your browser!
378378

379379
### Prerequisites
380380

381-
- Node.js 18+ and npm
381+
- Node.js 25+ and npm
382382
- macOS, Linux, or Windows with WSL
383383

384384
### Option 1: Using Make (Recommended)
@@ -482,8 +482,8 @@ docker pull bocan/codex:latest
482482

483483
**Available tags**:
484484
- `latest` - Latest stable release
485-
- `2.7.0` - Specific version (example)
486-
- `2.7` - Minor version (example)
485+
- `2.16.0` - Specific version (example)
486+
- `2.16` - Minor version (example)
487487
- `2` - Major version (example)
488488

489489
**Image verification** (signed with Cosign):
@@ -1037,31 +1037,31 @@ The TOC appears as a floating widget on the right side of the preview pane when
10371037
## 💻 Tech Stack
10381038

10391039
### Backend
1040-
- **[Express](https://expressjs.com/)** `^4.18.2` - Fast, unopinionated web framework
1040+
- **[Express](https://expressjs.com/)** `^5.2.1` - Fast, unopinionated web framework
10411041
- **[TypeScript](https://www.typescriptlang.org/)** `^5.3.3` - Type-safe JavaScript
1042-
- **[CORS](https://www.npmjs.com/package/cors)** `^2.8.5` - Cross-origin resource sharing
1042+
- **[CORS](https://www.npmjs.com/package/cors)** `^2.8.6` - Cross-origin resource sharing
10431043
- **[ts-node-dev](https://www.npmjs.com/package/ts-node-dev)** `^2.0.0` - Development server with auto-reload
10441044

10451045
**Testing:**
1046-
- **[Jest](https://jestjs.io/)** `^29.7.0` - Testing framework
1047-
- **[Supertest](https://www.npmjs.com/package/supertest)** `^6.3.3` - HTTP assertion library
1046+
- **[Jest](https://jestjs.io/)** `^30.2.0` - Testing framework
1047+
- **[Supertest](https://www.npmjs.com/package/supertest)** `^7.2.2` - HTTP assertion library
10481048
- **[ts-jest](https://www.npmjs.com/package/ts-jest)** `^29.1.1` - TypeScript preprocessor for Jest
10491049

10501050
### Frontend
1051-
- **[React](https://reactjs.org/)** `^18.2.0` - UI library
1051+
- **[React](https://reactjs.org/)** `^19.2.4` - UI library
10521052
- **[TypeScript](https://www.typescriptlang.org/)** `^5.3.3` - Type-safe JavaScript
1053-
- **[Vite](https://vitejs.dev/)** `^5.0.11` - Next-generation frontend tooling
1054-
- **[React Markdown](https://www.npmjs.com/package/react-markdown)** `^9.0.1` - Markdown renderer
1053+
- **[Vite](https://vitejs.dev/)** `^7.3.1` - Next-generation frontend tooling
1054+
- **[React Markdown](https://www.npmjs.com/package/react-markdown)** `^10.1.0` - Markdown renderer
10551055
- **[remark-gfm](https://www.npmjs.com/package/remark-gfm)** `^4.0.0` - GitHub Flavored Markdown
1056-
- **[Axios](https://axios-http.com/)** `^1.6.5` - HTTP client
1056+
- **[Axios](https://axios-http.com/)** `^1.13.4` - HTTP client
10571057

10581058
**Testing:**
1059-
- **[Vitest](https://vitest.dev/)** `^1.1.3` - Unit test framework
1059+
- **[Vitest](https://vitest.dev/)** `^4.0.18` - Unit test framework
10601060
- **[Testing Library](https://testing-library.com/)** - React testing utilities
1061-
- **[jsdom](https://www.npmjs.com/package/jsdom)** `^23.2.0` - DOM implementation
1061+
- **[jsdom](https://www.npmjs.com/package/jsdom)** `^28.0.0` - DOM implementation
10621062

10631063
### Development Tools
1064-
- **[Concurrently](https://www.npmjs.com/package/concurrently)** `^8.2.2` - Run multiple commands
1064+
- **[Concurrently](https://www.npmjs.com/package/concurrently)** `^9.2.1` - Run multiple commands
10651065
- **ESLint** - Code linting
10661066
- **Prettier** - Code formatting (optional)
10671067

data/Codex Documentation/README.md

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
99
[![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue)](https://www.typescriptlang.org/)
1010
[![React](https://img.shields.io/badge/React-19-61dafb)](https://reactjs.org/)
11-
[![Express](https://img.shields.io/badge/Express-4.18-green)](https://expressjs.com/)
11+
[![Express](https://img.shields.io/badge/Express-5.2.1-green)](https://expressjs.com/)
1212

1313
## ✨ Features
1414

1515
- 📁 **Folder Management**: Create, delete, and rename folders in a collapsible tree view with right-click context menus
1616
- 📝 **Markdown Pages**: Create and edit markdown documents with GitHub Flavored Markdown support
17+
- 🧩 **Smart Templates**: Create new pages from reusable templates (stored under `data/templates/`)
18+
- 📊 **Mermaid Diagrams**: Render Mermaid code fences in preview/reading mode, with export/download support
1719
- 🎨 **Three-Pane Layout**: Folder tree (left), markdown editor (center), live preview (right)
1820
- 📐 **Fully Resizable**: Drag to resize both horizontal panes (left/right) and vertical sections (folder tree/page list)
1921
- 🌓 **Theme Options**: Auto-detects system theme preference with manual override - cycles through auto/light/dark/high-contrast modes
@@ -38,7 +40,32 @@
3840
- 🔐 **Password Protection**: Simple password-based authentication to secure your data
3941
- 🛡️ **Security Features**: Rate limiting, request logging, and security headers
4042

41-
## 🔐 Security & Logging.
43+
## 🧩 Smart Templates
44+
45+
When creating a new page, Codex can start from a template instead of a blank page.
46+
47+
- Templates live in `data/templates/*.md`
48+
- Optional frontmatter at the top of the template file:
49+
- `template: Your Template Name` (display name)
50+
- `autoname: true|false` (auto-generate a filename when creating)
51+
- The frontmatter is stripped from the created page content automatically
52+
53+
## 📊 Mermaid Diagrams
54+
55+
Codex supports Mermaid diagrams in markdown via fenced code blocks:
56+
57+
````md
58+
```mermaid
59+
graph TD
60+
A --> B
61+
```
62+
````
63+
64+
- Diagrams render in the live preview and in reading mode (open in new window)
65+
- You can download rendered diagrams as SVG
66+
- Export flows (e.g. Word/PDF) include diagrams as images rather than raw Mermaid text
67+
68+
## 🔐 Security & Logging
4269

4370
Codex includes several security features to protect your data:
4471

@@ -351,7 +378,7 @@ Then open [http://localhost:3000](http://localhost:3000) in your browser!
351378

352379
### Prerequisites
353380

354-
- Node.js 18+ and npm
381+
- Node.js 25+ and npm
355382
- macOS, Linux, or Windows with WSL
356383

357384
### Option 1: Using Make (Recommended)
@@ -455,8 +482,8 @@ docker pull bocan/codex:latest
455482

456483
**Available tags**:
457484
- `latest` - Latest stable release
458-
- `2.7.0` - Specific version (example)
459-
- `2.7` - Minor version (example)
485+
- `2.16.0` - Specific version (example)
486+
- `2.16` - Minor version (example)
460487
- `2` - Major version (example)
461488

462489
**Image verification** (signed with Cosign):
@@ -523,6 +550,9 @@ docker stop codex && docker rm codex
523550
**Volume Mounting**:
524551
- `./data:/app/data` - Persists your wiki data outside the container
525552

553+
**Templates on first run**:
554+
- The Docker image includes built-in starter templates; on first startup, if `data/templates/` is missing or empty, Codex will copy the defaults into it.
555+
526556
### Authentication in Docker
527557

528558
**Important**: Due to secure cookie requirements, there are two ways to run Codex with authentication:
@@ -1007,31 +1037,31 @@ The TOC appears as a floating widget on the right side of the preview pane when
10071037
## 💻 Tech Stack
10081038

10091039
### Backend
1010-
- **[Express](https://expressjs.com/)** `^4.18.2` - Fast, unopinionated web framework
1040+
- **[Express](https://expressjs.com/)** `^5.2.1` - Fast, unopinionated web framework
10111041
- **[TypeScript](https://www.typescriptlang.org/)** `^5.3.3` - Type-safe JavaScript
1012-
- **[CORS](https://www.npmjs.com/package/cors)** `^2.8.5` - Cross-origin resource sharing
1042+
- **[CORS](https://www.npmjs.com/package/cors)** `^2.8.6` - Cross-origin resource sharing
10131043
- **[ts-node-dev](https://www.npmjs.com/package/ts-node-dev)** `^2.0.0` - Development server with auto-reload
10141044

10151045
**Testing:**
1016-
- **[Jest](https://jestjs.io/)** `^29.7.0` - Testing framework
1017-
- **[Supertest](https://www.npmjs.com/package/supertest)** `^6.3.3` - HTTP assertion library
1046+
- **[Jest](https://jestjs.io/)** `^30.2.0` - Testing framework
1047+
- **[Supertest](https://www.npmjs.com/package/supertest)** `^7.2.2` - HTTP assertion library
10181048
- **[ts-jest](https://www.npmjs.com/package/ts-jest)** `^29.1.1` - TypeScript preprocessor for Jest
10191049

10201050
### Frontend
1021-
- **[React](https://reactjs.org/)** `^18.2.0` - UI library
1051+
- **[React](https://reactjs.org/)** `^19.2.4` - UI library
10221052
- **[TypeScript](https://www.typescriptlang.org/)** `^5.3.3` - Type-safe JavaScript
1023-
- **[Vite](https://vitejs.dev/)** `^5.0.11` - Next-generation frontend tooling
1024-
- **[React Markdown](https://www.npmjs.com/package/react-markdown)** `^9.0.1` - Markdown renderer
1053+
- **[Vite](https://vitejs.dev/)** `^7.3.1` - Next-generation frontend tooling
1054+
- **[React Markdown](https://www.npmjs.com/package/react-markdown)** `^10.1.0` - Markdown renderer
10251055
- **[remark-gfm](https://www.npmjs.com/package/remark-gfm)** `^4.0.0` - GitHub Flavored Markdown
1026-
- **[Axios](https://axios-http.com/)** `^1.6.5` - HTTP client
1056+
- **[Axios](https://axios-http.com/)** `^1.13.4` - HTTP client
10271057

10281058
**Testing:**
1029-
- **[Vitest](https://vitest.dev/)** `^1.1.3` - Unit test framework
1059+
- **[Vitest](https://vitest.dev/)** `^4.0.18` - Unit test framework
10301060
- **[Testing Library](https://testing-library.com/)** - React testing utilities
1031-
- **[jsdom](https://www.npmjs.com/package/jsdom)** `^23.2.0` - DOM implementation
1061+
- **[jsdom](https://www.npmjs.com/package/jsdom)** `^28.0.0` - DOM implementation
10321062

10331063
### Development Tools
1034-
- **[Concurrently](https://www.npmjs.com/package/concurrently)** `^8.2.2` - Run multiple commands
1064+
- **[Concurrently](https://www.npmjs.com/package/concurrently)** `^9.2.1` - Run multiple commands
10351065
- **ESLint** - Code linting
10361066
- **Prettier** - Code formatting (optional)
10371067

server/src/services/fileSystem.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,39 @@ export class FileSystemService {
121121
await fs.mkdir(this.dataDir, { recursive: true });
122122
}
123123

124+
await this.syncBuiltinDocsIfConfigured();
124125
await this.seedTemplatesIfConfigured();
125126
}
126127

128+
private async syncBuiltinDocsIfConfigured(): Promise<void> {
129+
if (process.env.CODEX_SYNC_BUILTIN_DOCS !== "true") {
130+
return;
131+
}
132+
133+
const seedDir = process.env.CODEX_SYNC_BUILTIN_DOCS_DIR;
134+
if (!seedDir) {
135+
return;
136+
}
137+
138+
const sourceReadme = path.join(seedDir, "Codex Documentation", "README.md");
139+
const destReadmeRelative = path.join("Codex Documentation", "README.md");
140+
141+
try {
142+
const destDir = this.validatePath("Codex Documentation");
143+
await fs.mkdir(destDir, { recursive: true });
144+
145+
const destReadme = this.validatePath(destReadmeRelative);
146+
await fs.copyFile(sourceReadme, destReadme);
147+
148+
// Invalidate caches that might be affected
149+
this.cache.invalidate("folder-tree:");
150+
this.cache.invalidate("pages:Codex Documentation");
151+
this.cache.invalidate(`page:${destReadmeRelative}`);
152+
} catch {
153+
// Best-effort sync; ignore failures to avoid blocking startup
154+
}
155+
}
156+
127157
private async seedTemplatesIfConfigured(): Promise<void> {
128158
if (process.env.CODEX_SEED_TEMPLATES !== "true") {
129159
return;

0 commit comments

Comments
 (0)