diff --git a/Dockerfile b/Dockerfile index 701b8a1..14f3c0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,21 +17,26 @@ RUN chmod +x bin/chronicle.js RUN ln -s /app/packages/chronicle/bin/chronicle.js /usr/local/bin/chronicle # --- init project --- -WORKDIR /docs +WORKDIR /content RUN bun add /app/packages/chronicle RUN chronicle init # --- runner --- FROM base AS runner -WORKDIR /docs +WORKDIR /content -COPY --from=builder /docs /docs +COPY --from=builder /content /content COPY --from=builder /app/packages/chronicle /app/packages/chronicle +COPY --from=deps /app/package.json /app/bun.lock /app/ +COPY --from=deps /app/packages/chronicle/package.json /app/packages/chronicle/ +WORKDIR /app +RUN bun install --production --frozen-lockfile +WORKDIR /content RUN ln -s /app/packages/chronicle/bin/chronicle.js /usr/local/bin/chronicle -VOLUME /docs/content +VOLUME /content EXPOSE 3000 ENTRYPOINT ["chronicle"] -CMD ["serve", "--port", "3000"] +CMD ["serve", "--port", "3000", "--host", "0.0.0.0"] diff --git a/docs/cli.mdx b/docs/cli.mdx index 0cd7330..3d615a2 100644 --- a/docs/cli.mdx +++ b/docs/cli.mdx @@ -40,6 +40,7 @@ chronicle dev [options] | `--content ` | Content directory | `content` | | `--config ` | Path to `chronicle.yaml` | `./chronicle.yaml` | | `-p, --port ` | Port number | `3000` | +| `--host ` | Host address | `localhost` | ## build @@ -67,6 +68,7 @@ chronicle start [options] |------|-------------|---------| | `--content ` | Content directory | `content` | | `-p, --port ` | Port number | `3000` | +| `--host ` | Host address | `localhost` | ## serve @@ -81,6 +83,7 @@ chronicle serve [options] | `--content ` | Content directory | `content` | | `--config ` | Path to `chronicle.yaml` | `./chronicle.yaml` | | `-p, --port ` | Port number | `3000` | +| `--host ` | Host address | `localhost` | | `--preset ` | Deploy preset (`vercel`, `cloudflare`, `node-server`) | — | ## Resolution Order diff --git a/docs/docker.mdx b/docs/docker.mdx index 4e0a252..75eaf10 100644 --- a/docs/docker.mdx +++ b/docs/docker.mdx @@ -19,23 +19,23 @@ docker pull raystack/chronicle The default command builds and starts a production server on port 3000. ```bash -docker run -p 3000:3000 -v ./content:/docs/content raystack/chronicle +docker run -p 3000:3000 -v ./content:/content raystack/chronicle ``` -Mount your content directory (containing MDX files) to `/docs/content`. Place `chronicle.yaml` in the content directory or it will use defaults. +Mount your content directory (containing MDX files) to `/content`. Place `chronicle.yaml` in the content directory or it will use defaults. ## Development Server Override the default command with `dev` for hot reload: ```bash -docker run -p 3000:3000 -v ./content:/docs/content raystack/chronicle dev --port 3000 +docker run -p 3000:3000 -v ./content:/content raystack/chronicle dev --port 3000 ``` ## Custom Port ```bash -docker run -p 8080:8080 -v ./content:/docs/content raystack/chronicle serve --port 8080 +docker run -p 8080:8080 -v ./content:/content raystack/chronicle serve --port 8080 ``` ## Docker Compose @@ -47,7 +47,7 @@ services: ports: - "3000:3000" volumes: - - ./content:/docs/content + - ./content:/content ``` ## Available Commands @@ -56,11 +56,11 @@ The entrypoint is `chronicle`, so any CLI command can be passed: ```bash # Build only -docker run -v ./content:/docs/content raystack/chronicle build +docker run -v ./content:/content raystack/chronicle build # Start pre-built server -docker run -p 3000:3000 -v ./content:/docs/content raystack/chronicle start --port 3000 +docker run -p 3000:3000 -v ./content:/content raystack/chronicle start --port 3000 # Build and start (default) -docker run -p 3000:3000 -v ./content:/docs/content raystack/chronicle serve --port 3000 +docker run -p 3000:3000 -v ./content:/content raystack/chronicle serve --port 3000 ``` diff --git a/packages/chronicle/src/cli/commands/dev.ts b/packages/chronicle/src/cli/commands/dev.ts index 3d73b6d..b34853c 100644 --- a/packages/chronicle/src/cli/commands/dev.ts +++ b/packages/chronicle/src/cli/commands/dev.ts @@ -9,6 +9,7 @@ export const devCommand = new Command('dev') .option('-p, --port ', 'Port number', '3000') .option('--content ', 'Content directory') .option('--config ', 'Path to chronicle.yaml') + .option('--host ', 'Host address', 'localhost') .action(async options => { const { contentDir, configPath } = await loadCLIConfig(options.config, { content: options.content }); const port = parseInt(options.port, 10); @@ -23,7 +24,7 @@ export const devCommand = new Command('dev') const config = await createViteConfig({ packageRoot: PACKAGE_ROOT, projectRoot: process.cwd(), contentDir, configPath }); const server = await createServer({ ...config, - server: { ...config.server, port } + server: { ...config.server, port, host: options.host } }); await server.listen(); diff --git a/packages/chronicle/src/cli/commands/serve.ts b/packages/chronicle/src/cli/commands/serve.ts index 0af33a2..14062c7 100644 --- a/packages/chronicle/src/cli/commands/serve.ts +++ b/packages/chronicle/src/cli/commands/serve.ts @@ -9,6 +9,7 @@ export const serveCommand = new Command('serve') .option('-p, --port ', 'Port number', '3000') .option('--content ', 'Content directory') .option('--config ', 'Path to chronicle.yaml') + .option('--host ', 'Host address', 'localhost') .option( '--preset ', 'Deploy preset (vercel, cloudflare, node-server)' @@ -38,7 +39,7 @@ export const serveCommand = new Command('serve') console.log(chalk.cyan('Starting production server...')); const server = await preview({ ...config, - preview: { port } + preview: { port, host: options.host } }); server.printUrls(); diff --git a/packages/chronicle/src/cli/commands/start.ts b/packages/chronicle/src/cli/commands/start.ts index 8603942..2626b30 100644 --- a/packages/chronicle/src/cli/commands/start.ts +++ b/packages/chronicle/src/cli/commands/start.ts @@ -8,6 +8,7 @@ export const startCommand = new Command('start') .description('Start production server') .option('-p, --port ', 'Port number', '3000') .option('--content ', 'Content directory') + .option('--host ', 'Host address', 'localhost') .action(async options => { const { contentDir, configPath } = await loadCLIConfig(undefined, { content: options.content }); const port = parseInt(options.port, 10); @@ -21,7 +22,7 @@ export const startCommand = new Command('start') const config = await createViteConfig({ packageRoot: PACKAGE_ROOT, projectRoot: process.cwd(), contentDir, configPath }); const server = await preview({ ...config, - preview: { port } + preview: { port, host: options.host } }); server.printUrls();