@@ -497,6 +497,43 @@ STATUS_HEADER
497497 update_status "⚠ DDEV global config: Warning (non-critical)"
498498 fi
499499
500+ # Write Coder-specific DDEV config so 'ddev describe' shows usable URLs.
501+ # Runs every workspace start so the config stays current.
502+ # project_tld is set to the Coder subdomain suffix so DDEV's primary URL
503+ # resolves to <project-name>.<workspace>--<owner>.<coder-domain> rather
504+ # than the default <project-name>.ddev.site.
505+ if [ -n "$VSCODE_PROXY_URI" ] && [ -n "$CODER_WORKSPACE_OWNER_NAME" ]; then
506+ CODER_DOMAIN=$(echo "$VSCODE_PROXY_URI" | sed -E 's|https?://[^.]+\.(.+?)(/.*)?$|\1|')
507+ cat > .ddev/config.coder.yaml << CODER_YAML_EOF
508+ # Auto-generated by workspace startup -- do not edit.
509+ # Sets project_tld so 'ddev describe' shows the Coder domain rather than ddev.site.
510+ project_tld: "$${CODER_WORKSPACE_NAME}--$${CODER_WORKSPACE_OWNER_NAME}.$${CODER_DOMAIN}"
511+ use_dns_when_possible: false
512+ # Bind mailpit directly to workspace localhost (ddev-router is omitted in this template).
513+ # Without this, mailpit is only reachable inside the DDEV web container.
514+ host_mailpit_port: "8025"
515+ # Show Coder URLs after every ddev start/restart (appended after DDEV's own message).
516+ hooks:
517+ post-start:
518+ - exec-host: 'echo "" && echo " Site: https://drupal-site--$${CODER_WORKSPACE_NAME}--$${CODER_WORKSPACE_OWNER_NAME}.$${CODER_DOMAIN}" && echo " Mailpit: https://mailpit--$${CODER_WORKSPACE_NAME}--$${CODER_WORKSPACE_OWNER_NAME}.$${CODER_DOMAIN}" && echo ""'
519+ CODER_YAML_EOF
520+ log_setup "✓ .ddev/config.coder.yaml written (project_tld: $${CODER_WORKSPACE_NAME}--$${CODER_WORKSPACE_OWNER_NAME}.$${CODER_DOMAIN})"
521+
522+ # Generate docker-compose override that adds Coder URLs and credentials to
523+ # 'ddev describe' output via x-ddev labels on the web service.
524+ cat > .ddev/docker-compose.coder-describe.yaml << COMPOSE_EOF
525+ # Auto-generated by workspace startup -- do not edit.
526+ services:
527+ web:
528+ x-ddev:
529+ describe-url-port: |
530+ https://drupal-site--$${CODER_WORKSPACE_NAME}--$${CODER_WORKSPACE_OWNER_NAME}.$${CODER_DOMAIN}
531+ Mailpit: https://mailpit--$${CODER_WORKSPACE_NAME}--$${CODER_WORKSPACE_OWNER_NAME}.$${CODER_DOMAIN}
532+ describe-info: "Admin: admin / admin"
533+ COMPOSE_EOF
534+ log_setup "✓ .ddev/docker-compose.coder-describe.yaml written (x-ddev describe labels)"
535+ fi
536+
500537 # Step 3: Start DDEV
501538 # poweroff first — ddev-router can persist in Docker's state across workspace
502539 # stop/start; `ddev stop` only stops project containers, not ddev-router.
@@ -578,66 +615,29 @@ STATUS_HEADER
578615 fi
579616
580617 # Create Drupal-specific welcome message (first run only, now that issue info is available)
581- if [ ! -f ~/WELCOME.txt ]; then
582- {
583- cat << 'WELCOME_STATIC'
584- ╔═══════════════════════════════════════════════════════════════╗
585- ║ Welcome to Drupal Core Development ║
586- ╚═══════════════════════════════════════════════════════════════╝
587-
588- This workspace uses joachim-n/drupal-core-development-project
589- for a professional Drupal core development setup.
590-
591- 🌐 ACCESS YOUR SITE
592- Click "DDEV Web" in the Coder dashboard
593- Or run: ddev launch
594-
595- 🔐 ADMIN CREDENTIALS
596- Username: admin
597- Password: admin
598- One-time link: ddev drush uli
599-
600- 📁 PROJECT STRUCTURE
601- /home/coder/drupal-core # Project root
602- /home/coder/drupal-core/repos/drupal # Drupal core git clone
603- /home/coder/drupal-core/web # Web docroot
604-
605- 🛠️ USEFUL COMMANDS
606- ddev drush status # Check Drupal status
607- ddev drush uli # Get admin login link
608- ddev logs # View container logs
609- ddev ssh # SSH into web container
610- ddev describe # Show project details
611- ddev composer require ... # Add dependencies
612-
613- 📚 DOCUMENTATION
614- Quickstart: https://github.com/ddev/coder-ddev/blob/main/docs/user/quickstart.md
615- DDEV: https://docs.ddev.com/
616- Drupal: https://www.drupal.org/docs
617- Drupal API: https://api.drupal.org/
618- Project Template: https://github.com/joachim-n/drupal-core-development-project
619-
620- 📋 SETUP STATUS
621- ~/SETUP_STATUS.txt # Setup completion status
622- /tmp/drupal-setup.log # Detailed setup logs
623-
624- 💡 TROUBLESHOOTING
625- If setup failed, check the status and log files above.
626- You can manually run setup steps from the log.
627-
628- Good luck with your Drupal core development!
618+ {
619+ cat << 'WELCOME_STATIC'
620+ Drupal Core Development Workspace
621+ ==================================
622+ Admin: admin / admin
623+
624+ Commands:
625+ ddev launch # Show site URL and one-time login link
626+ ddev describe # Show project details and URLs
627+ ddev drush status # Check Drupal status
628+ ddev logs # View container logs
629+ ddev ssh # SSH into web container
630+
631+ Docs: https://docs.ddev.com/
629632WELCOME_STATIC
630633
631- if [ -n "$ISSUE_FORK" ]; then
632- echo ""
633- echo "🐛 WORKING ON ISSUE"
634- echo " #$${ISSUE_FORK}: $${ISSUE_TITLE}"
635- echo " https://www.drupal.org/project/drupal/issues/$${ISSUE_FORK}"
636- fi
637- } > ~/WELCOME.txt
638- chown coder:coder ~/WELCOME.txt 2>/dev/null || true
639- echo "✓ Created Drupal-specific welcome message"
640- fi
634+ if [ -n "$ISSUE_FORK" ]; then
635+ echo ""
636+ echo "Issue #$${ISSUE_FORK}: $${ISSUE_TITLE}"
637+ echo " https://www.drupal.org/project/drupal/issues/$${ISSUE_FORK}"
638+ fi
639+ } > ~/WELCOME.txt
640+ chown coder:coder ~/WELCOME.txt 2>/dev/null || true
641641
642642 # Step 4: Set up Drupal core project — use seed cache for main branch only (fast path)
643643 # Issue forks and non-main plain versions (10.x, 11.x) skip the cache: the seed
@@ -1054,60 +1054,58 @@ WELCOME_STATIC
10541054 cat > ~/.ddev/commands/host/launch << 'LAUNCH_EOF'
10551055#!/usr/bin/env bash
10561056
1057- ## Description: Launch a browser with the current site
1058- ## Usage: launch
1059- ## Example: "ddev launch"
1057+ ## Description: Show Coder URLs for this Drupal workspace
1058+ ## Usage: launch [path] [-m|--mailpit]
1059+ ## Example: "ddev launch" or "ddev launch /admin" or "ddev launch -m"
1060+ ## Flags: [{"Name":"mailpit","Shorthand":"m","Usage":"ddev launch -m shows the Mailpit URL"}]
10601061
1061- # Get the primary port (should be 80)
1062- PRIMARY_PORT=$(ddev describe -j 2>/dev/null | grep -o '"router_http_port":"[^"]*"' | cut -d'"' -f4)
1063- if [ -z "$PRIMARY_PORT" ]; then
1064- PRIMARY_PORT="80"
1062+ # Outside a Coder workspace fall back to a basic URL print (no browser available in DinD)
1063+ if [ -z "$${CODER_WORKSPACE_NAME:-}" ] || [ -z "$${VSCODE_PROXY_URI:-}" ]; then
1064+ echo "Primary URL: $${DDEV_PRIMARY_URL:-unknown}"
1065+ echo "(Not running in a Coder workspace; cannot open a browser.)"
1066+ exit 0
10651067fi
10661068
1067- # In Coder environment, show access information
1068- if [ -n "$CODER_WORKSPACE_NAME" ]; then
1069- echo ""
1070- echo "╔═══════════════════════════════════════════════════╗"
1071- echo "║ Your Drupal Site is Running! ║"
1072- echo "╚═══════════════════════════════════════════════════╝"
1073- echo ""
1069+ WORKSPACE="$${CODER_WORKSPACE_NAME}"
1070+ OWNER="$${CODER_WORKSPACE_OWNER_NAME}"
1071+ DOMAIN=$(echo "$${VSCODE_PROXY_URI}" | sed -E 's|https?://[^.]+\.(.+?)(/.*)?$|\1|')
1072+ MAILPIT=false
1073+ PATH_SUFFIX=""
1074+
1075+ while :; do
1076+ case $${1:-} in
1077+ -m | --mailpit | --mailhog) MAILPIT=true ;;
1078+ --) shift; break ;;
1079+ -?*) printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2 ;;
1080+ *) break ;;
1081+ esac
1082+ shift
1083+ done
1084+
1085+ if [ -n "$${1:-}" ]; then
1086+ PATH_SUFFIX="/$${1#/}"
1087+ fi
10741088
1075- # Construct the Coder app proxy URL
1076- # Coder apps with subdomain=true create URLs like: https://<port>--<workspace>--<owner>.<coder-domain>
1077- # Extract Coder base domain from VSCODE_PROXY_URI if available
1078- CODER_DOMAIN=""
1079- if [ -n "$VSCODE_PROXY_URI" ]; then
1080- # Extract domain from VS Code proxy URI (format: https://something--something--something.domain.com)
1081- CODER_DOMAIN=$(echo "$VSCODE_PROXY_URI" | sed -E 's|https?://[^.]+\.(.+?)(/.*)?$|\1|')
1082- fi
1083-
1084- if [ -n "$CODER_DOMAIN" ] && [ -n "$CODER_WORKSPACE_OWNER_NAME" ]; then
1085- # Construct the URL using Coder's subdomain pattern
1086- APP_URL="https://$${PRIMARY_PORT}--$${CODER_WORKSPACE_NAME}--$${CODER_WORKSPACE_OWNER_NAME}.$${CODER_DOMAIN}"
1087- echo "🌐 Your Drupal Site:"
1088- echo " $${APP_URL}"
1089- echo ""
1090- else
1091- echo "🌐 Access Your Site:"
1092- echo " Click the 'DDEV Web' app button in your workspace"
1093- echo ""
1094- fi
1089+ if [ "$${MAILPIT}" = "true" ]; then
1090+ echo "https://mailpit--$${WORKSPACE}--$${OWNER}.$${DOMAIN}"
1091+ exit 0
1092+ fi
10951093
1096- echo "🔐 Admin Login:"
1097- echo " Username: admin"
1098- echo " Password: admin"
1099- echo ""
1100- echo "✨ Quick Commands:"
1101- echo " ddev drush uli # Get one-time login link"
1102- echo " ddev drush status # Check Drupal status"
1103- echo " ddev logs # View container logs"
1104- echo ""
1094+ SITE_URL="https://drupal-site--$${WORKSPACE}--$${OWNER}.$${DOMAIN}"
1095+
1096+ echo ""
1097+ echo "Coder URLs for this Drupal workspace:"
1098+ echo " Site: $${SITE_URL}$${PATH_SUFFIX}"
1099+ echo " Mailpit: https://mailpit--$${WORKSPACE}--$${OWNER}.$${DOMAIN}"
1100+ echo ""
1101+ echo "Admin login: admin / admin"
1102+ ULI=$(ddev drush uli --uri="$${SITE_URL}" 2>/dev/null || true)
1103+ if [ -n "$${ULI}" ]; then
1104+ echo "One-time login: $${ULI}"
11051105else
1106- # Outside Coder, use standard browser launch
1107- xdg-open "http://localhost:$${PRIMARY_PORT}" 2>/dev/null || \
1108- open "http://localhost:$${PRIMARY_PORT}" 2>/dev/null || \
1109- echo "Open http://localhost:$${PRIMARY_PORT} in your browser"
1106+ echo "One-time login: ddev drush uli (run when Drupal is installed)"
11101107fi
1108+ echo ""
11111109LAUNCH_EOF
11121110
11131111 chmod +x ~/.ddev/commands/host/launch
@@ -1369,6 +1367,23 @@ resource "coder_app" "drupal-site" {
13691367 }
13701368}
13711369
1370+ resource "coder_app" "mailpit" {
1371+ agent_id = coder_agent. main . id
1372+ slug = " mailpit"
1373+ display_name = " Mailpit"
1374+ order = 3
1375+ url = " http://localhost:8025"
1376+ icon = " https://raw.githubusercontent.com/axllent/mailpit/develop/server/ui/public/favicon.svg"
1377+ subdomain = true
1378+ share = " owner"
1379+
1380+ healthcheck {
1381+ url = " http://localhost:8025"
1382+ interval = 10
1383+ threshold = 10
1384+ }
1385+ }
1386+
13721387# Note: JetBrains IDEs (PhpStorm, GoLand, WebStorm, etc.) are supported via JetBrains Gateway
13731388# Users should install JetBrains Gateway locally and use the Coder plugin to connect
13741389# No explicit app definitions needed - coder-login module enables Gateway support
0 commit comments