Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

feat: configurable ports for dashboard and mailhog#968

Merged
dbarrosop merged 2 commits into
nhost:jovermier-mainfrom
jovermier:main
Jun 23, 2025
Merged

feat: configurable ports for dashboard and mailhog#968
dbarrosop merged 2 commits into
nhost:jovermier-mainfrom
jovermier:main

Conversation

@jovermier
Copy link
Copy Markdown

@jovermier jovermier commented Jun 7, 2025

Description

feat: configurable ports for Dashboard and Mailhog services

Problem

The Nhost CLI supports custom ports for most services such as Hasura, Auth, and Postgres, but the ports for the Dashboard and Mailhog services are currently hardcoded. This limits the ability of developers to avoid port conflicts or customize their local environment, particularly when running multiple Nhost instances simultaneously.

Solution

This PR adds two new CLI flags and associated support throughout the codebase to allow customization of Dashboard and Mailhog ports:

  • --dashboard-port with env fallback NHOST_DASHBOARD_PORT
  • --mailhog-port with env fallback NHOST_MAILHOG_PORT

Key implementation updates:

  • Introduced new UintFlag definitions for both ports in cmd/dev/up.go.
  • Extended the ExposePorts struct to include Dashboard and Mailhog fields.
  • Updated service creation functions (dashboard, mailhog) to accept the new ports and apply them using the ports() utility.
  • Adjusted getServices() to pass the port values correctly to each respective service.
  • Ensured printInfo() remains consistent and informative with the correct URLs displayed (though it still prints the base HTTP port for Dashboard and Mailhog to preserve the current behavior; further enhancements to output format could be addressed in a future PR).

Notes

  • Default behavior remains unchanged if the new flags are not specified.
  • This brings Dashboard and Mailhog in line with other services for port configurability.
  • Enables better local dev experience with multiple environments or custom tooling.

Example usage:

nhost up \
  --dashboard-port 3001 \
  --mailhog-port 8026

Closes #967

Copilot AI review requested due to automatic review settings June 7, 2025 16:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for user-defined host ports for the Dashboard and Mailhog services via new CLI flags and underlying compose wiring.

  • Introduces --dashboard-port / --mailhog-port flags (with intended env var fallbacks) in cmd/dev/up.go.
  • Extends ExposePorts and service constructors in dockercompose/compose.go to wire host ports into container definitions.
  • Updates getServices() calls to pass the new port values into dashboard and mailhog.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
cmd/dev/up.go Added two new UintFlags for dashboard and mailhog ports and wired them into ExposePorts.
dockercompose/compose.go Expanded service constructors and ExposePorts to accept host ports and updated Ports binding logic.
Comments suppressed due to low confidence (3)

dockercompose/compose.go:315

  • [nitpick] The port parameter is ambiguous; consider renaming it to hostPort or dashboardHostPort to distinguish it from the container’s dashboardPort constant.
func dashboard(

dockercompose/compose.go:448

  • [nitpick] The port parameter overlaps with the container port constant mailhogPort; consider renaming to hostPort or mailhogHostPort for clarity.
func mailhog(subdomain, volumeName string, useTLS bool, port uint) *Service {

cmd/dev/up.go:186

  • New port flags aren’t covered by existing CLI tests; add a test case to verify parsing and application of --dashboard-port and --mailhog-port.
Dashboard:   cCtx.Uint(flagDashboardPort),

Comment thread cmd/dev/up.go
Usage: "If specified, expose hasura console on this port. Not recommended",
Value: 0,
},
&cli.UintFlag{ //nolint:exhaustruct
Copy link

Copilot AI Jun 7, 2025

Choose a reason for hiding this comment

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

Env var fallbacks (NHOST_DASHBOARD_PORT) are mentioned in the PR description but not implemented; add EnvVars: []string{"NHOST_DASHBOARD_PORT"} to this flag.

Copilot uses AI. Check for mistakes.
Comment thread cmd/dev/up.go
Usage: "If specified, expose dashboard on this port. Not recommended",
Value: 0,
},
&cli.UintFlag{ //nolint:exhaustruct
Copy link

Copilot AI Jun 7, 2025

Choose a reason for hiding this comment

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

Env var fallbacks (NHOST_MAILHOG_PORT) are mentioned in the PR description but not implemented; add EnvVars: []string{"NHOST_MAILHOG_PORT"} to this flag.

Copilot uses AI. Check for mistakes.
@dbarrosop dbarrosop changed the base branch from main to jovermier-main June 23, 2025 07:33
@dbarrosop dbarrosop merged commit a175a93 into nhost:jovermier-main Jun 23, 2025
4 of 7 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configurable Ports for Dashboard and Mailhog

3 participants