Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: Change default serve port to 3000 and add ability to override #265

Merged
merged 5 commits into from
Jan 20, 2025

Conversation

reakaleek
Copy link
Member

@reakaleek reakaleek commented Jan 17, 2025

Closes #229

Changes

Changing default port to 3000 as it is a common port for local web development.

In the world of web development, localhost:3000 is a popular shorthand for localhost port 3000, the default port used by many web servers. It is often used to talk about development environments and is often the first port that web apps use to run.

Read more here: https://locall.host/3000/

Source: https://locall.host/3000/

However, this change also gives the ability to override the port if necessary.

% dotnet run -- serve --help                
Usage: serve [options...] [-h|--help] [--version]

Continuously serve a documentation folder at http://localhost:3000.
         File systems changes will be reflected without having to restart the server.

Options:
  -p|--path <string?>    Path to serve the documentation.
         Defaults to the`{pwd}/docs` folder (Default: null)
  --port <int>           Port to serve the documentation. (Default: 3000)

@reakaleek
Copy link
Member Author

reakaleek commented Jan 17, 2025

I understand that changing the default port can introduce some disruption.

But it's a very common port for local web development. Hence, I still wanted to suggest it.

Another major reason is https://stackoverflow.com/questions/69818376/localhost5000-unavailable-in-macos-v12-monterey/69829313#69829313

TL;DR some macOS service named AirPlay somehow utilizes the port 5000. And I actually encountered this problem myself. This could cause many errors for all macOS users in the future.

@reakaleek reakaleek changed the title Change default serve port to 3000 and add ability to override Breaking: Change default serve port to 3000 and add ability to override Jan 17, 2025
@reakaleek reakaleek self-assigned this Jan 17, 2025
@reakaleek reakaleek requested a review from a team January 17, 2025 12:35
@reakaleek reakaleek changed the title Breaking: Change default serve port to 3000 and add ability to override BREAKING CHANGE: Change default serve port to 3000 and add ability to override Jan 17, 2025
@reakaleek
Copy link
Member Author

Also, I'm afraid this affects the docker image. I couldn't find how it serves on port 8080


// See https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_running_in_container-and-dotnet_running_in_containers
// This way use the default port when running in a container
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER")) &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking one will suffice 😸 both will be set (don't ask my why!).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay 😅

c9b04bb

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to wonder.

IIUC, the main reason for the differing ports for the native binary and the docker image are dotnet defaults.

Would it be a better UX if both use the same port?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://learn.microsoft.com/en-us/dotnet/core/compatibility/containers/8.0/aspnet-port has some background as to why its 8080.

In .net the default changes based on environments: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-9.0

Which is not something we leverage. Docker is a prod environments hence the different port as the rest of the run environments which are dev by default..

It makes sense to normalize this to one non privileged port and forego the docker env check to keep it simple.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I understand correctly? We skip the environment check and always do UseUrls?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes thats the less long winded conclusion 😸

We'll have to update https://github.com/elastic/docs-builder-example or maybe we should archive that repository now that we have the migration repositories.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reakaleek reakaleek requested a review from Mpdreamz January 20, 2025 12:03
@reakaleek reakaleek merged commit bfa8b3b into main Jan 20, 2025
4 checks passed
@reakaleek reakaleek deleted the feature/serve-port branch January 20, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow serving docs on a customized port
2 participants