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
Conversation
There was a problem hiding this comment.
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-portflags (with intended env var fallbacks) incmd/dev/up.go. - Extends
ExposePortsand service constructors indockercompose/compose.goto wire host ports into container definitions. - Updates
getServices()calls to pass the new port values intodashboardandmailhog.
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
portparameter is ambiguous; consider renaming it tohostPortordashboardHostPortto distinguish it from the container’sdashboardPortconstant.
func dashboard(
dockercompose/compose.go:448
- [nitpick] The
portparameter overlaps with the container port constantmailhogPort; consider renaming tohostPortormailhogHostPortfor 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-portand--mailhog-port.
Dashboard: cCtx.Uint(flagDashboardPort),
| Usage: "If specified, expose hasura console on this port. Not recommended", | ||
| Value: 0, | ||
| }, | ||
| &cli.UintFlag{ //nolint:exhaustruct |
There was a problem hiding this comment.
Env var fallbacks (NHOST_DASHBOARD_PORT) are mentioned in the PR description but not implemented; add EnvVars: []string{"NHOST_DASHBOARD_PORT"} to this flag.
| Usage: "If specified, expose dashboard on this port. Not recommended", | ||
| Value: 0, | ||
| }, | ||
| &cli.UintFlag{ //nolint:exhaustruct |
There was a problem hiding this comment.
Env var fallbacks (NHOST_MAILHOG_PORT) are mentioned in the PR description but not implemented; add EnvVars: []string{"NHOST_MAILHOG_PORT"} to this flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-portwith env fallbackNHOST_DASHBOARD_PORT--mailhog-portwith env fallbackNHOST_MAILHOG_PORTKey implementation updates:
UintFlagdefinitions for both ports incmd/dev/up.go.ExposePortsstruct to includeDashboardandMailhogfields.dashboard,mailhog) to accept the new ports and apply them using theports()utility.getServices()to pass the port values correctly to each respective service.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
Example usage:
Closes #967