Skip to content

Commit bfa8b3b

Browse files
authored
BREAKING CHANGE: Change default serve port to 3000 and add ability to override (#265)
* Change default serve port to 3000 and add ability to override * Fix documentation comment * Only change the webhost url if not running in a container * Refactor and simplify * Always use default port
1 parent 4a134ec commit bfa8b3b

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Options:
2525

2626
Commands:
2727
generate Converts a source markdown folder or file to an output folder
28-
serve Continuously serve a documentation folder at http://localhost:5000.
28+
serve Continuously serve a documentation folder at http://localhost:3000.
2929
File systems changes will be reflected without having to restart the server.
3030
```
3131

@@ -63,10 +63,10 @@ Through the `serve` command you can continuously and partially compile your docu
6363

6464
```bash
6565
docker run -v "./.git:/app/.git" -v "./docs:/app/docs" -v "./.artifacts:/app/.artifacts" \
66-
-p 8080:8080 ghcr.io/elastic/docs-builder:edge serve
66+
-p 3000:3000 ghcr.io/elastic/docs-builder:edge serve
6767
```
6868

69-
Each page is compiled on demand as you browse http://localhost:8080 and is never cached so changes to files and
69+
Each page is compiled on demand as you browse http://localhost:3000 and is never cached so changes to files and
7070
navigation will always be reflected upon refresh.
7171

7272
Note the docker image is `linux-x86` and will be somewhat slower to invoke on OSX due to virtualization.

docs/source/contribute/locally.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Follow these steps to contribute to Elastic docs.
2727
```
2828

2929
3. **Run the Binary:**
30-
Use the `serve` command to start serving the documentation at http://localhost:5000. The path to the docset.yml file that you want to build can be specified with `-p`:
30+
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the docset.yml file that you want to build can be specified with `-p`:
3131
```sh
3232
./docs-builder serve -p ./path/to/docs
3333
```
@@ -51,7 +51,7 @@ Follow these steps to contribute to Elastic docs.
5151
```
5252

5353
3. **Run the Binary:**
54-
Use the `serve` command to start serving the documentation at http://localhost:5000. The path to the docset.yml file that you want to build can be specified with `-p`:
54+
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the docset.yml file that you want to build can be specified with `-p`:
5555
```sh
5656
.\docs-builder serve -p ./path/to/docs
5757
```
@@ -75,7 +75,7 @@ Follow these steps to contribute to Elastic docs.
7575
```
7676

7777
3. **Run the Binary:**
78-
Use the `serve` command to start serving the documentation at http://localhost:5000. The path to the docset.yml file that you want to build can be specified with `-p`:
78+
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the docset.yml file that you want to build can be specified with `-p`:
7979
```sh
8080
./docs-builder serve -p ./path/to/docs
8181
```
@@ -99,7 +99,7 @@ git clone https://github.com/elastic/docs-content.git
9999
```
100100

101101
2. **Run the Binary:**
102-
Use the `serve` command to start serving the documentation at http://localhost:5000. The path to the `docset.yml` file that you want to build can be specified with `-p`:
102+
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the `docset.yml` file that you want to build can be specified with `-p`:
103103
```sh
104104
# macOS/Linux
105105
./docs-builder serve -p ./migration-test
@@ -108,7 +108,7 @@ git clone https://github.com/elastic/docs-content.git
108108
.\docs-builder serve -p .\migration-test
109109
```
110110

111-
Now you should be able to view the documentation locally by navigating to http://localhost:5000.
111+
Now you should be able to view the documentation locally by navigating to http://localhost:3000.
112112

113113
## Step 4: Open a PR [#step-four]
114114

src/docs-builder/Cli/Commands.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ namespace Documentation.Builder.Cli;
1616
internal class Commands(ILoggerFactory logger, ICoreService githubActionsService)
1717
{
1818
/// <summary>
19-
/// Continuously serve a documentation folder at http://localhost:5000.
19+
/// Continuously serve a documentation folder at http://localhost:3000.
2020
/// File systems changes will be reflected without having to restart the server.
2121
/// </summary>
2222
/// <param name="path">-p, Path to serve the documentation.
2323
/// Defaults to the`{pwd}/docs` folder
2424
/// </param>
25+
/// <param name="port">Port to serve the documentation.</param>
2526
/// <param name="ctx"></param>
2627
[Command("serve")]
27-
public async Task Serve(string? path = null, Cancel ctx = default)
28+
public async Task Serve(string? path = null, int port = 3000, Cancel ctx = default)
2829
{
29-
var host = new DocumentationWebHost(path, logger, new FileSystem());
30+
var host = new DocumentationWebHost(path, port, logger, new FileSystem());
3031
await host.RunAsync(ctx);
3132
await host.StopAsync(ctx);
32-
3333
}
3434

3535
/// <summary>

src/docs-builder/Http/DocumentationWebHost.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Elastic.Markdown.Diagnostics;
1111
using Elastic.Markdown.IO;
1212
using Microsoft.AspNetCore.Builder;
13+
using Microsoft.AspNetCore.Hosting;
1314
using Microsoft.AspNetCore.Http;
1415
using Microsoft.Extensions.DependencyInjection;
1516
using Microsoft.Extensions.FileProviders;
@@ -28,7 +29,7 @@ public class DocumentationWebHost
2829

2930
private readonly BuildContext _context;
3031

31-
public DocumentationWebHost(string? path, ILoggerFactory logger, IFileSystem fileSystem)
32+
public DocumentationWebHost(string? path, int port, ILoggerFactory logger, IFileSystem fileSystem)
3233
{
3334
var builder = WebApplication.CreateSlimBuilder();
3435

@@ -54,6 +55,8 @@ public DocumentationWebHost(string? path, ILoggerFactory logger, IFileSystem fil
5455

5556
//builder.Services.AddSingleton(logger);
5657

58+
builder.WebHost.UseUrls($"http://localhost:{port}");
59+
5760
_webApplication = builder.Build();
5861
SetUpRoutes();
5962
}

0 commit comments

Comments
 (0)