Skip to content

Commit 6896b08

Browse files
rsbhclaude
andauthored
feat: add --host flag to CLI and fix Docker setup (#30)
* feat: add --host flag to dev, start, and serve commands Allows binding to a custom host address (defaults to localhost). Use --host 0.0.0.0 for Docker container port mapping. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: add --host flag to CLI and fix Docker setup Add --host flag (default: localhost) to dev, start, and serve commands for Docker container port mapping. Fix Dockerfile by copying node_modules to runner stage and using /content as working directory. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * docs: add --host flag to CLI docs and fix Docker mount paths Update cli.mdx with --host flag for dev, start, and serve commands. Update docker.mdx to use /content mount path matching Dockerfile changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: use production install in Docker runner stage Replace copying full node_modules with bun install --production in the runner stage for a smaller image with only runtime dependencies. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2bd664c commit 6896b08

6 files changed

Lines changed: 27 additions & 16 deletions

File tree

Dockerfile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,26 @@ RUN chmod +x bin/chronicle.js
1717
RUN ln -s /app/packages/chronicle/bin/chronicle.js /usr/local/bin/chronicle
1818

1919
# --- init project ---
20-
WORKDIR /docs
20+
WORKDIR /content
2121
RUN bun add /app/packages/chronicle
2222
RUN chronicle init
2323

2424
# --- runner ---
2525
FROM base AS runner
26-
WORKDIR /docs
26+
WORKDIR /content
2727

28-
COPY --from=builder /docs /docs
28+
COPY --from=builder /content /content
2929
COPY --from=builder /app/packages/chronicle /app/packages/chronicle
30+
COPY --from=deps /app/package.json /app/bun.lock /app/
31+
COPY --from=deps /app/packages/chronicle/package.json /app/packages/chronicle/
32+
WORKDIR /app
33+
RUN bun install --production --frozen-lockfile
34+
WORKDIR /content
3035
RUN ln -s /app/packages/chronicle/bin/chronicle.js /usr/local/bin/chronicle
3136

32-
VOLUME /docs/content
37+
VOLUME /content
3338

3439
EXPOSE 3000
3540

3641
ENTRYPOINT ["chronicle"]
37-
CMD ["serve", "--port", "3000"]
42+
CMD ["serve", "--port", "3000", "--host", "0.0.0.0"]

docs/cli.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ chronicle dev [options]
4040
| `--content <path>` | Content directory | `content` |
4141
| `--config <path>` | Path to `chronicle.yaml` | `./chronicle.yaml` |
4242
| `-p, --port <port>` | Port number | `3000` |
43+
| `--host <host>` | Host address | `localhost` |
4344

4445
## build
4546

@@ -67,6 +68,7 @@ chronicle start [options]
6768
|------|-------------|---------|
6869
| `--content <path>` | Content directory | `content` |
6970
| `-p, --port <port>` | Port number | `3000` |
71+
| `--host <host>` | Host address | `localhost` |
7072

7173
## serve
7274

@@ -81,6 +83,7 @@ chronicle serve [options]
8183
| `--content <path>` | Content directory | `content` |
8284
| `--config <path>` | Path to `chronicle.yaml` | `./chronicle.yaml` |
8385
| `-p, --port <port>` | Port number | `3000` |
86+
| `--host <host>` | Host address | `localhost` |
8487
| `--preset <preset>` | Deploy preset (`vercel`, `cloudflare`, `node-server`) ||
8588

8689
## Resolution Order

docs/docker.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ docker pull raystack/chronicle
1919
The default command builds and starts a production server on port 3000.
2020

2121
```bash
22-
docker run -p 3000:3000 -v ./content:/docs/content raystack/chronicle
22+
docker run -p 3000:3000 -v ./content:/content raystack/chronicle
2323
```
2424

25-
Mount your content directory (containing MDX files) to `/docs/content`. Place `chronicle.yaml` in the content directory or it will use defaults.
25+
Mount your content directory (containing MDX files) to `/content`. Place `chronicle.yaml` in the content directory or it will use defaults.
2626

2727
## Development Server
2828

2929
Override the default command with `dev` for hot reload:
3030

3131
```bash
32-
docker run -p 3000:3000 -v ./content:/docs/content raystack/chronicle dev --port 3000
32+
docker run -p 3000:3000 -v ./content:/content raystack/chronicle dev --port 3000
3333
```
3434

3535
## Custom Port
3636

3737
```bash
38-
docker run -p 8080:8080 -v ./content:/docs/content raystack/chronicle serve --port 8080
38+
docker run -p 8080:8080 -v ./content:/content raystack/chronicle serve --port 8080
3939
```
4040

4141
## Docker Compose
@@ -47,7 +47,7 @@ services:
4747
ports:
4848
- "3000:3000"
4949
volumes:
50-
- ./content:/docs/content
50+
- ./content:/content
5151
```
5252
5353
## Available Commands
@@ -56,11 +56,11 @@ The entrypoint is `chronicle`, so any CLI command can be passed:
5656

5757
```bash
5858
# Build only
59-
docker run -v ./content:/docs/content raystack/chronicle build
59+
docker run -v ./content:/content raystack/chronicle build
6060
6161
# Start pre-built server
62-
docker run -p 3000:3000 -v ./content:/docs/content raystack/chronicle start --port 3000
62+
docker run -p 3000:3000 -v ./content:/content raystack/chronicle start --port 3000
6363
6464
# Build and start (default)
65-
docker run -p 3000:3000 -v ./content:/docs/content raystack/chronicle serve --port 3000
65+
docker run -p 3000:3000 -v ./content:/content raystack/chronicle serve --port 3000
6666
```

packages/chronicle/src/cli/commands/dev.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const devCommand = new Command('dev')
99
.option('-p, --port <port>', 'Port number', '3000')
1010
.option('--content <path>', 'Content directory')
1111
.option('--config <path>', 'Path to chronicle.yaml')
12+
.option('--host <host>', 'Host address', 'localhost')
1213
.action(async options => {
1314
const { contentDir, configPath } = await loadCLIConfig(options.config, { content: options.content });
1415
const port = parseInt(options.port, 10);
@@ -23,7 +24,7 @@ export const devCommand = new Command('dev')
2324
const config = await createViteConfig({ packageRoot: PACKAGE_ROOT, projectRoot: process.cwd(), contentDir, configPath });
2425
const server = await createServer({
2526
...config,
26-
server: { ...config.server, port }
27+
server: { ...config.server, port, host: options.host }
2728
});
2829

2930
await server.listen();

packages/chronicle/src/cli/commands/serve.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const serveCommand = new Command('serve')
99
.option('-p, --port <port>', 'Port number', '3000')
1010
.option('--content <path>', 'Content directory')
1111
.option('--config <path>', 'Path to chronicle.yaml')
12+
.option('--host <host>', 'Host address', 'localhost')
1213
.option(
1314
'--preset <preset>',
1415
'Deploy preset (vercel, cloudflare, node-server)'
@@ -38,7 +39,7 @@ export const serveCommand = new Command('serve')
3839
console.log(chalk.cyan('Starting production server...'));
3940
const server = await preview({
4041
...config,
41-
preview: { port }
42+
preview: { port, host: options.host }
4243
});
4344

4445
server.printUrls();

packages/chronicle/src/cli/commands/start.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const startCommand = new Command('start')
88
.description('Start production server')
99
.option('-p, --port <port>', 'Port number', '3000')
1010
.option('--content <path>', 'Content directory')
11+
.option('--host <host>', 'Host address', 'localhost')
1112
.action(async options => {
1213
const { contentDir, configPath } = await loadCLIConfig(undefined, { content: options.content });
1314
const port = parseInt(options.port, 10);
@@ -21,7 +22,7 @@ export const startCommand = new Command('start')
2122
const config = await createViteConfig({ packageRoot: PACKAGE_ROOT, projectRoot: process.cwd(), contentDir, configPath });
2223
const server = await preview({
2324
...config,
24-
preview: { port }
25+
preview: { port, host: options.host }
2526
});
2627

2728
server.printUrls();

0 commit comments

Comments
 (0)