This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch make-ports-open
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 98753f6fddfb339edb5b9ac06213ddff3f432145
Author: Evan Rusackas <[email protected]>
AuthorDate: Mon Jan 5 10:38:35 2026 -0800

    feat(dev): add make ports and make open commands
    
    Adds two new commands to improve developer experience when running
    Superset via Docker:
    
    - `make ports` - Shows the assigned URLs and ports for running services
    - `make open` - Opens the browser directly to the dev server
    
    Also improves the docker-compose-up.sh script to:
    - Print connection info again when exiting with Ctrl+C
    - Detect actual ports from running containers (not just find new ones)
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Co-Authored-By: Claude Opus 4.5 <[email protected]>
---
 Makefile                                           |  8 ++-
 .../contributing/development-setup.md              |  2 +
 scripts/docker-compose-up.sh                       | 77 ++++++++++++++++++----
 3 files changed, 73 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index 9d0a73c9e7..3c35fb4c60 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@
 # Python version installed; we need 3.10-3.11
 PYTHON=`command -v python3.11 || command -v python3.10`
 
-.PHONY: install superset venv pre-commit up down logs ps nuke
+.PHONY: install superset venv pre-commit up down logs ps nuke ports open
 
 install: superset pre-commit
 
@@ -131,3 +131,9 @@ ps:
 
 nuke:
        ./scripts/docker-compose-up.sh nuke
+
+ports:
+       ./scripts/docker-compose-up.sh ports
+
+open:
+       ./scripts/docker-compose-up.sh open
diff --git a/docs/developer_portal/contributing/development-setup.md 
b/docs/developer_portal/contributing/development-setup.md
index 464c70a73c..cd173d24a4 100644
--- a/docs/developer_portal/contributing/development-setup.md
+++ b/docs/developer_portal/contributing/development-setup.md
@@ -164,6 +164,8 @@ Available commands (run from repo root):
 | `make down` | Stop all services |
 | `make ps` | Show running containers |
 | `make logs` | Follow container logs |
+| `make ports` | Show assigned URLs and ports |
+| `make open` | Open browser to dev server |
 | `make nuke` | Stop, remove volumes & local images |
 
 From a subdirectory, use: `make -C $(git rev-parse --show-toplevel) up`
diff --git a/scripts/docker-compose-up.sh b/scripts/docker-compose-up.sh
index 525d07e3c2..66adb405bc 100755
--- a/scripts/docker-compose-up.sh
+++ b/scripts/docker-compose-up.sh
@@ -114,6 +114,32 @@ find_and_claim_port $BASE_REDIS REDIS_PORT
 
 # Export for docker-compose
 export COMPOSE_PROJECT_NAME="$PROJECT_NAME"
+
+# Function to get port from running container, or use the found available port
+get_running_port() {
+    local service=$1
+    local container_port=$2
+    local fallback=$3
+    local running_port=$(docker compose port "$service" "$container_port" 
2>/dev/null | cut -d: -f2)
+    if [[ -n "$running_port" ]]; then
+        echo "$running_port"
+    else
+        echo "$fallback"
+    fi
+}
+
+# Check if containers are running and get actual ports, otherwise use 
available ports
+cd "$REPO_ROOT"
+if docker compose ps --status running 2>/dev/null | grep -q "$PROJECT_NAME"; 
then
+    # Containers are running - get actual ports
+    NGINX_PORT=$(get_running_port nginx 80 $NGINX_PORT)
+    SUPERSET_PORT=$(get_running_port superset 8088 $SUPERSET_PORT)
+    NODE_PORT=$(get_running_port superset-node 9000 $NODE_PORT)
+    WEBSOCKET_PORT=$(get_running_port superset-websocket 8080 $WEBSOCKET_PORT)
+    DATABASE_PORT=$(get_running_port db 5432 $DATABASE_PORT)
+    REDIS_PORT=$(get_running_port redis 6379 $REDIS_PORT)
+fi
+
 export NGINX_PORT
 export SUPERSET_PORT
 export NODE_PORT
@@ -122,19 +148,32 @@ export CYPRESS_PORT
 export DATABASE_PORT
 export REDIS_PORT
 
-echo ""
-echo "🐳 Starting Superset with:"
-echo "   Project:    $PROJECT_NAME"
-echo "   Superset:   http://localhost:$SUPERSET_PORT";
-echo "   Dev Server: http://localhost:$NODE_PORT";
-echo "   Nginx:      http://localhost:$NGINX_PORT";
-echo "   WebSocket:  localhost:$WEBSOCKET_PORT"
-echo "   Database:   localhost:$DATABASE_PORT"
-echo "   Redis:      localhost:$REDIS_PORT"
-echo ""
-
-# Change to repo root
-cd "$REPO_ROOT"
+# Function to print connection info
+print_connection_info() {
+    echo ""
+    echo "🐳 Superset ($PROJECT_NAME):"
+    echo "   Dev Server: http://localhost:$NODE_PORT  ← Use this for 
development"
+    echo "   Superset:   http://localhost:$SUPERSET_PORT";
+    echo "   Nginx:      http://localhost:$NGINX_PORT";
+    echo "   WebSocket:  localhost:$WEBSOCKET_PORT"
+    echo "   Database:   localhost:$DATABASE_PORT"
+    echo "   Redis:      localhost:$REDIS_PORT"
+    echo ""
+}
+
+# Function to open browser (macOS/Linux compatible)
+open_browser() {
+    local url="http://localhost:$NODE_PORT";
+    if command -v open &> /dev/null; then
+        open "$url"  # macOS
+    elif command -v xdg-open &> /dev/null; then
+        xdg-open "$url"  # Linux
+    else
+        echo "Open in browser: $url"
+    fi
+}
+
+print_connection_info
 
 # Handle special commands
 case "${1:-}" in
@@ -154,6 +193,16 @@ case "${1:-}" in
         echo "export REDIS_PORT=$REDIS_PORT"
         exit 0
         ;;
+    ports)
+        # Just show the ports (already printed above)
+        exit 0
+        ;;
+    open)
+        # Open browser to the dev server
+        echo "🌐 Opening browser..."
+        open_browser
+        exit 0
+        ;;
     down|stop|logs|ps|exec|restart)
         # Pass through to docker compose
         docker compose "$@"
@@ -166,6 +215,8 @@ case "${1:-}" in
         ;;
     *)
         # Default: start services
+        # Print connection info again when user exits (Ctrl+C)
+        trap 'echo ""; print_connection_info; echo "Run '\''make open'\'' to 
open browser, '\''make ports'\'' to see ports"' EXIT
         docker compose up "$@"
         ;;
 esac

Reply via email to