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

feat: improve how ddev describe or ddev st show exposed ports #6699

Merged
merged 12 commits into from
Nov 19, 2024

Conversation

hanoii
Copy link
Collaborator

@hanoii hanoii commented Nov 7, 2024

This PR improves:

  • provides ports in a list, rather and on a CSV, as projects with a lot of ports doesn't displays nicely.
  • gives a clear distinction between privately exposed ports (namely InDocker and the Host ports.
  • Ports are sorted by the internal container ports

I've always been bothered by this. More often than not I want to clearly find what are the mappings of the local port to the remote ports. Also, onn some projects I exposed quite a bit of ports, and there are duplicate ports on the hosts

This is the second time I bring this up, couldn't find my previous issue though, but I hadn't worked on it back than.

On this project, for example, I exposed port 4000. As I have many ports I couldn't really tell which host port was connected to container port 4000. I can find it with docker ps or some other inspection tools ,but it would be great if it was there and provided by ddev.

Somewhat related, this is the reason why I had to create https://github.com/hanoii/ddev-platformsh-lite/blob/main/commands/host/platform%3Atunnels on my not publicly exposed add-on.

Hope this doesn't takes as much as ddev debug match-constraint 😄

Showing example of how it is displayed currently, vs the PR:

┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Project: foo ~/Sites/bar/foo https://foo.ddev.site                                                                                                                                                                                                                                                                                         │
│ Docker platform: orbstack                                                                                                                                                                                                                                                                                                                  │
│ Router: traefik                                                                                                                                                                                                                                                                                                                            │
├──────────┬──────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬────────────────────┤
│ SERVICE  │ STAT │ URL/PORT                                                                                                                                                                                                                                                                                            │ INFO               │
├──────────┼──────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼────────────────────┤
│ web      │ OK   │ https://foo.ddev.site                                                                                                                                                                                                                                                                               │ drupal10 PHP8.2    │
│          │      │ InDocker: web:30006,30007,30010,30013,30018,4000,80,30001,30003,30011,30014,30015,30020,30004,30009,30016,443,8025,30019,30000,30002,30005,30008,30012,30017                                                                                                                                        │ nginx-fpm          │
│          │      │ Host: 127.0.0.1:32884,32884,32894,32894,32897,32897,32890,32890,32893,32893,32896,32896,32898,32898,32895,32895,32878,32878,32803,32879,32879,32881,32881,32882,32882,32887,32887,32888,32888,32891,32891,32892,32892,32899,32899,32880,32880,32883,32883,32885,32885,32886,32886,32889,32889,32804 │ docroot:'web'      │
│          │      │                                                                                                                                                                                                                                                                                                     │ Perf mode: mutagen │
│          │      │                                                                                                                                                                                                                                                                                                     │ NodeJS:18.18.2     │
├──────────┼──────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼────────────────────┤
│ db       │ OK   │ InDocker: db:3306                                                                                                                                                                                                                                                                                   │ mariadb:10.11      │
│          │      │ Host: 127.0.0.1:32800                                                                                                                                                                                                                                                                               │ User/Pass: 'db/db' │
│          │      │                                                                                                                                                                                                                                                                                                     │ or 'root/root'     │
├──────────┼──────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼────────────────────┤
│ Mailpit  │      │ Mailpit: https://foo.ddev.site:8026                                                                                                                                                                                                                                                                 │                    │
│          │      │ Launch: ddev mailpit                                                                                                                                                                                                                                                                                │                    │
├──────────┼──────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼────────────────────┤
│ All URLs │      │ https://foo.ddev.site, https://*.foo.ddev.site,                                                                                                                                                                                                                                                     │                    │
│          │      │ https://127.0.0.1:32804, http://foo.ddev.site,                                                                                                                                                                                                                                                      │                    │
│          │      │ http://*.foo.ddev.site, http://127.0.0.1:32803                                                                                                                                                                                                                                                      │                    │
└──────────┴──────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴────────────────────┘
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Project: foo ~/Sites/bar/foo https://foo.ddev.site                                                       │
│ Docker platform: orbstack                                                                                │
│ Router: traefik                                                                                          │
├──────────┬──────┬───────────────────────────────────────────────────────────────────┬────────────────────┤
│ SERVICE  │ STAT │ URL/PORT                                                          │ INFO               │
├──────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ web      │ OK   │ https://foo.ddev.site                                             │ drupal10 PHP8.2    │
│          │      │ InDocker:                                                         │ nginx-fpm          │
│          │      │   - web:8025                                                      │ docroot:'web'      │
│          │      │ Host:                                                             │ Perf mode: mutagen │
│          │      │   - 127.0.0.1:32803->80                                           │ NodeJS:18.18.2     │
│          │      │   - 127.0.0.1:32804->443                                          │                    │
│          │      │   - 127.0.0.1:32878->4000                                         │                    │
│          │      │   - 127.0.0.1:32879->30000                                        │                    │
│          │      │   - 127.0.0.1:32880->30001                                        │                    │
│          │      │   - 127.0.0.1:32881->30002                                        │                    │
│          │      │   - 127.0.0.1:32882->30003                                        │                    │
│          │      │   - 127.0.0.1:32883->30004                                        │                    │
│          │      │   - 127.0.0.1:32884->30005                                        │                    │
│          │      │   - 127.0.0.1:32885->30006                                        │                    │
│          │      │   - 127.0.0.1:32886->30007                                        │                    │
│          │      │   - 127.0.0.1:32887->30008                                        │                    │
│          │      │   - 127.0.0.1:32888->30009                                        │                    │
│          │      │   - 127.0.0.1:32889->30010                                        │                    │
│          │      │   - 127.0.0.1:32890->30011                                        │                    │
│          │      │   - 127.0.0.1:32891->30012                                        │                    │
│          │      │   - 127.0.0.1:32892->30013                                        │                    │
│          │      │   - 127.0.0.1:32893->30014                                        │                    │
│          │      │   - 127.0.0.1:32894->30015                                        │                    │
│          │      │   - 127.0.0.1:32895->30016                                        │                    │
│          │      │   - 127.0.0.1:32896->30017                                        │                    │
│          │      │   - 127.0.0.1:32897->30018                                        │                    │
│          │      │   - 127.0.0.1:32898->30019                                        │                    │
│          │      │   - 127.0.0.1:32899->30020                                        │                    │
├──────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ db       │ OK   │ InDocker: db                                                      │ mariadb:10.11      │
│          │      │ Host:                                                             │ User/Pass: 'db/db' │
│          │      │   - 127.0.0.1:32800->3306                                         │ or 'root/root'     │
├──────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ Mailpit  │      │ Mailpit: https://foo.ddev.site:8026                               │                    │
│          │      │ Launch: ddev mailpit                                              │                    │
├──────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ All URLs │      │ https://foo.ddev.site, https://*.foo.ddev.site,                   │                    │
│          │      │ https://127.0.0.1:32804, http://foo.ddev.site,                    │                    │
│          │      │ http://*.foo.ddev.site, http://127.0.0.1:32803                    │                    │
└──────────┴──────┴───────────────────────────────────────────────────────────────────┴────────────────────┘

@hanoii hanoii requested a review from a team as a code owner November 7, 2024 15:18
@hanoii
Copy link
Collaborator Author

hanoii commented Nov 7, 2024

edited description after my latest commit

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 7, 2024

Forgot to mention that the ports are sorted by the container ports - adding to main comment

Copy link
Member

@stasadev stasadev left a comment

Choose a reason for hiding this comment

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

This is really amazing, thank you very much @hanoii !

It's much better than what we already have.

I tested it with installed ddev/ddev-phpmyadmin add-on. And used this .ddev/docker-compose.ports.yaml:

services:
  web:
    expose:
      - 5492
      - 12394
      - 57497
    ports:
      - 5332:5222
      - 5555:5777
      - 12445
  db:
    expose:
      - 6594
      - 4352
    ports:
      - 12312:3999
      - 54355
  phpmyadmin:
    expose:
      - 8983
      - 12345
    ports:
      - 5000:5000
      - 5001:5605
      - 1234:14556

Usual test:

before

┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Project: d11 ~/code/ddev/d11 https://d11.ddev.site                                                   │
│ Docker platform: linux-docker                                                                        │
│ Router: traefik                                                                                      │
├────────────┬──────┬─────────────────────────────────────────────────────────────┬────────────────────┤
│ SERVICE    │ STAT │ URL/PORT                                                    │ INFO               │
├────────────┼──────┼─────────────────────────────────────────────────────────────┼────────────────────┤
│ web        │ OK   │ https://d11.ddev.site                                       │ php PHP8.3         │
│            │      │ InDocker: web:57497,5777,8025,443,12445,5222,5492,80,12394  │ nginx-fpm          │
│            │      │ Host: 127.0.0.1:5332,5332,5555,5555,33043,32795,32795,33044 │ docroot:''         │
│            │      │                                                             │ Perf mode: none    │
│            │      │                                                             │ NodeJS:20          │
├────────────┼──────┼─────────────────────────────────────────────────────────────┼────────────────────┤
│ db         │ OK   │ InDocker: db:3306,3999,4352,54355,6594                      │ mysql:8.0          │
│            │      │ Host: 127.0.0.1:33045,12312,12312,32796,32796               │ User/Pass: 'db/db' │
│            │      │                                                             │ or 'root/root'     │
├────────────┼──────┼─────────────────────────────────────────────────────────────┼────────────────────┤
│ phpmyadmin │ OK   │ https://d11.ddev.site:8037                                  │                    │
│            │      │ InDocker: phpmyadmin:80,80,8983,12345,14556,5000,5605       │                    │
│            │      │ Host: 127.0.0.1:1234,1234,5000,5000,5001,5001               │                    │
├────────────┼──────┼─────────────────────────────────────────────────────────────┼────────────────────┤
│ Mailpit    │      │ Mailpit: https://d11.ddev.site:8026                         │                    │
│            │      │ Launch: ddev mailpit                                        │                    │
├────────────┼──────┼─────────────────────────────────────────────────────────────┼────────────────────┤
│ All URLs   │      │ https://d11.ddev.site, https://127.0.0.1:33044,             │                    │
│            │      │ http://d11.ddev.site, http://127.0.0.1:33043                │                    │
└────────────┴──────┴─────────────────────────────────────────────────────────────┴────────────────────┘

after

┌─────────────────────────────────────────────────────────────────────────────────────────────┐
│ Project: d11 ~/code/ddev/d11 https://d11.ddev.site                                          │
│ Docker platform: linux-docker                                                               │
│ Router: traefik                                                                             │
├────────────┬──────┬────────────────────────────────────────────────────┬────────────────────┤
│ SERVICE    │ STAT │ URL/PORT                                           │ INFO               │
├────────────┼──────┼────────────────────────────────────────────────────┼────────────────────┤
│ web        │ OK   │ https://d11.ddev.site                              │ php PHP8.3         │
│            │      │ InDocker:                                          │ nginx-fpm          │
│            │      │   - web:5492                                       │ docroot:''         │
│            │      │   - web:8025                                       │ Perf mode: none    │
│            │      │   - web:12394                                      │ NodeJS:20          │
│            │      │   - web:57497                                      │                    │
│            │      │ Host:                                              │                    │
│            │      │   - 127.0.0.1:33043->80                            │                    │
│            │      │   - 127.0.0.1:33044->443                           │                    │
│            │      │   - 127.0.0.1:5332->5222                           │                    │
│            │      │   - 127.0.0.1:5555->5777                           │                    │
│            │      │   - 127.0.0.1:32795->12445                         │                    │
├────────────┼──────┼────────────────────────────────────────────────────┼────────────────────┤
│ db         │ OK   │ InDocker:                                          │ mysql:8.0          │
│            │      │   - db:4352                                        │ User/Pass: 'db/db' │
│            │      │   - db:6594                                        │ or 'root/root'     │
│            │      │ Host:                                              │                    │
│            │      │   - 127.0.0.1:33045->3306                          │                    │
│            │      │   - 127.0.0.1:12312->3999                          │                    │
│            │      │   - 127.0.0.1:32796->54355                         │                    │
├────────────┼──────┼────────────────────────────────────────────────────┼────────────────────┤
│ phpmyadmin │ OK   │ https://d11.ddev.site:8037                         │                    │
│            │      │ InDocker:                                          │                    │
│            │      │   - phpmyadmin:80                                  │                    │
│            │      │   - phpmyadmin:8983                                │                    │
│            │      │   - phpmyadmin:12345                               │                    │
│            │      │ Host:                                              │                    │
│            │      │   - 127.0.0.1:5000->5000                           │                    │
│            │      │   - 127.0.0.1:5001->5605                           │                    │
│            │      │   - 127.0.0.1:1234->14556                          │                    │
├────────────┼──────┼────────────────────────────────────────────────────┼────────────────────┤
│ Mailpit    │      │ Mailpit: https://d11.ddev.site:8026                │                    │
│            │      │ Launch: ddev mailpit                               │                    │
├────────────┼──────┼────────────────────────────────────────────────────┼────────────────────┤
│ All URLs   │      │ https://d11.ddev.site, https://127.0.0.1:33044,    │                    │
│            │      │ http://d11.ddev.site, http://127.0.0.1:33043       │                    │
└────────────┴──────┴────────────────────────────────────────────────────┴────────────────────┘

Another test with ddev config global --omit-containers="ddev-router"

before

┌──────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Project: d11 ~/code/ddev/d11 http://127.0.0.1:33021                                                  │
│ Docker platform: linux-docker                                                                        │
│ Router: disabled                                                                                     │
├────────────┬──────┬─────────────────────────────────────────────────────────────┬────────────────────┤
│ SERVICE    │ STAT │ URL/PORT                                                    │ INFO               │
├────────────┼──────┼─────────────────────────────────────────────────────────────┼────────────────────┤
│ web        │ OK   │ http://127.0.0.1:33021                                      │ php PHP8.3         │
│            │      │ InDocker: web:12394,12445,443,57497,5222,5492,5777,80,8025  │ nginx-fpm          │
│            │      │ Host: 127.0.0.1:33023,5332,5332,32782,32782,33021,5555,5555 │ docroot:''         │
│            │      │                                                             │ Perf mode: none    │
│            │      │                                                             │ NodeJS:20          │
├────────────┼──────┼─────────────────────────────────────────────────────────────┼────────────────────┤
│ db         │ OK   │ InDocker: db:4352,54355,6594,3306,3999                      │ mysql:8.0          │
│            │      │ Host: 127.0.0.1:33022,12312,12312,32780,32780               │ User/Pass: 'db/db' │
│            │      │                                                             │ or 'root/root'     │
├────────────┼──────┼─────────────────────────────────────────────────────────────┼────────────────────┤
│ phpmyadmin │ OK   │ InDocker: phpmyadmin:12345,14556,5000,5605,80,80,8983       │                    │
│            │      │ Host: 127.0.0.1:5000,5000,5001,5001,8036,8036,1234,1234     │                    │
└────────────┴──────┴─────────────────────────────────────────────────────────────┴────────────────────┘

after

┌─────────────────────────────────────────────────────────────────────┐
│ Project: d11 ~/code/ddev/d11 http://127.0.0.1:33021                 │
│ Docker platform: linux-docker                                       │
│ Router: disabled                                                    │
├────────────┬──────┬────────────────────────────┬────────────────────┤
│ SERVICE    │ STAT │ URL/PORT                   │ INFO               │
├────────────┼──────┼────────────────────────────┼────────────────────┤
│ web        │ OK   │ http://127.0.0.1:33021     │ php PHP8.3         │
│            │      │ InDocker:                  │ nginx-fpm          │
│            │      │   - web:5492               │ docroot:''         │
│            │      │   - web:8025               │ Perf mode: none    │
│            │      │   - web:12394              │ NodeJS:20          │
│            │      │   - web:57497              │                    │
│            │      │ Host:                      │                    │
│            │      │   - 127.0.0.1:33021->80    │                    │
│            │      │   - 127.0.0.1:33023->443   │                    │
│            │      │   - 127.0.0.1:5332->5222   │                    │
│            │      │   - 127.0.0.1:5555->5777   │                    │
│            │      │   - 127.0.0.1:32782->12445 │                    │
├────────────┼──────┼────────────────────────────┼────────────────────┤
│ db         │ OK   │ InDocker:                  │ mysql:8.0          │
│            │      │   - db:4352                │ User/Pass: 'db/db' │
│            │      │   - db:6594                │ or 'root/root'     │
│            │      │ Host:                      │                    │
│            │      │   - 127.0.0.1:33022->3306  │                    │
│            │      │   - 127.0.0.1:12312->3999  │                    │
│            │      │   - 127.0.0.1:32780->54355 │                    │
├────────────┼──────┼────────────────────────────┼────────────────────┤
│ phpmyadmin │ OK   │ InDocker:                  │                    │
│            │      │   - phpmyadmin:8983        │                    │
│            │      │   - phpmyadmin:12345       │                    │
│            │      │ Host:                      │                    │
│            │      │   - 127.0.0.1:8036->80     │                    │
│            │      │   - 127.0.0.1:5000->5000   │                    │
│            │      │   - 127.0.0.1:5001->5605   │                    │
│            │      │   - 127.0.0.1:1234->14556  │                    │
└────────────┴──────┴────────────────────────────┴────────────────────┘

Gitpod:

before

┌────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Project: d10simple /workspace/code https://8080-ddev-ddevgitpodlaunch-9wh2a78be3v.ws-eu116.gitpod.io       │
│ Docker platform: linux-docker                                                                              │
│ Router: disabled                                                                                           │
├────────────┬──────┬───────────────────────────────────────────────────────────────────┬────────────────────┤
│ SERVICE    │ STAT │ URL/PORT                                                          │ INFO               │
├────────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ web        │ OK   │ https://8080-ddev-ddevgitpodlaunch-9wh2a78be3v.ws-eu116.gitpod.io │ drupal PHP8.3      │
│            │      │ InDocker: web:80,12445,443,5222,5492,12394,57497,5777,8025        │ nginx-fpm          │
│            │      │ Host: 127.0.0.1:8080,8443,5332,5332,5555,5555,32770,32770,8027    │ docroot:'web'      │
│            │      │                                                                   │ Perf mode: none    │
│            │      │                                                                   │ NodeJS:20          │
├────────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ db         │ OK   │ InDocker: db:3306,3999,4352,54355,6594                            │ mariadb:10.11      │
│            │      │ Host: 127.0.0.1:3306,12312,12312,32769,32769                      │ User/Pass: 'db/db' │
│            │      │                                                                   │ or 'root/root'     │
├────────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ phpmyadmin │ OK   │ InDocker: phpmyadmin:5000,5605,80,80,8983,12345,14556             │                    │
│            │      │ Host: 127.0.0.1:1234,1234,5000,5000,5001,5001,8036,8036           │                    │
├────────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ Network    │      │ bind-all-interfaces ENABLED                                       │                    │
└────────────┴──────┴───────────────────────────────────────────────────────────────────┴────────────────────┘

after

┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Project: d10simple /workspace/d10simple https://8080-hanoii-ddev-s6sreye647e.ws-eu116.gitpod.io  │
│ Docker platform: linux-docker                                                                    │
│ Router: disabled                                                                                 │
├────────────┬──────┬─────────────────────────────────────────────────────────┬────────────────────┤
│ SERVICE    │ STAT │ URL/PORT                                                │ INFO               │
├────────────┼──────┼─────────────────────────────────────────────────────────┼────────────────────┤
│ web        │ OK   │ https://8080-hanoii-ddev-s6sreye647e.ws-eu116.gitpod.io │ drupal PHP8.3      │
│            │      │ InDocker:                                               │ nginx-fpm          │
│            │      │   - web:5492                                            │ docroot:'web'      │
│            │      │   - web:12394                                           │ Perf mode: none    │
│            │      │   - web:57497                                           │ NodeJS:20          │
│            │      │ Host:                                                   │                    │
│            │      │   - 127.0.0.1:8080->80                                  │                    │
│            │      │   - 127.0.0.1:8443->443                                 │                    │
│            │      │   - 127.0.0.1:5332->5222                                │                    │
│            │      │   - 127.0.0.1:5555->5777                                │                    │
│            │      │   - 127.0.0.1:8027->8025                                │                    │
│            │      │   - 127.0.0.1:32771->12445                              │                    │
├────────────┼──────┼─────────────────────────────────────────────────────────┼────────────────────┤
│ db         │ OK   │ InDocker:                                               │ mariadb:10.11      │
│            │      │   - db:4352                                             │ User/Pass: 'db/db' │
│            │      │   - db:6594                                             │ or 'root/root'     │
│            │      │ Host:                                                   │                    │
│            │      │   - 127.0.0.1:3306->3306                                │                    │
│            │      │   - 127.0.0.1:12312->3999                               │                    │
│            │      │   - 127.0.0.1:32770->54355                              │                    │
├────────────┼──────┼─────────────────────────────────────────────────────────┼────────────────────┤
│ phpmyadmin │ OK   │ InDocker:                                               │                    │
│            │      │   - phpmyadmin:8983                                     │                    │
│            │      │   - phpmyadmin:12345                                    │                    │
│            │      │ Host:                                                   │                    │
│            │      │   - 127.0.0.1:8036->80                                  │                    │
│            │      │   - 127.0.0.1:5000->5000                                │                    │
│            │      │   - 127.0.0.1:5001->5605                                │                    │
│            │      │   - 127.0.0.1:1234->14556                               │                    │
├────────────┼──────┼─────────────────────────────────────────────────────────┼────────────────────┤
│ Network    │      │ bind-all-interfaces ENABLED                             │                    │
└────────────┴──────┴─────────────────────────────────────────────────────────┴────────────────────┘

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

I love this, it's an incredible improvement!

  • Could you please check test coverage?
  • Could you take a look at the "All URLs" and see if it might be possible to do something similar there? It's the exact same class of problem. Not trying to expand scope, but it does look like exactly the same problem. (The label is also ambigous, it's really just showing the primary http and https ports for the webserver.)
  • Don't forget about the json version, ddev describe -j. This breaks host_ports and exposed_ports:
    "web": {
      "exposed_ports": "  - web:5492\n  - web:8025\n  - web:12394\n  - web:57497",
      "full_name": "ddev-d11-web",
      "host_http_url": "http://127.0.0.1:32872",
      "host_https_url": "https://127.0.0.1:32871",
      "host_ports": "  - 127.0.0.1:32872->80\n  - 127.0.0.1:32871->443\n  - 127.0.0.1:5332->5222\n  - 127.0.0.1:5555->5777\n  - 127.0.0.1:32774->12445",
      "http_url": "http://d11.ddev.site",
      "https_url": "https://d11.ddev.site",
      "image": "ddev/ddev-webserver:20241031_improve_php_image_build",
      "short_name": "web",
      "status": "running",
      "virtual_host": "d11.ddev.site"
    }

I think the previous version was more parse-able:

    "web": {
      "exposed_ports": "12445,57497,80,12394,443,5222,5492,5777,8025",
      "full_name": "ddev-d11-web",
      "host_http_url": "http://127.0.0.1:32872",
      "host_https_url": "https://127.0.0.1:32871",
      "host_ports": "32774,32774,5332,5332,32872,32871,5555,5555",
      "http_url": "http://d11.ddev.site",
      "https_url": "https://d11.ddev.site",
      "image": "ddev/ddev-webserver:20241031_improve_php_image_build",
      "short_name": "web",
      "status": "running",
      "virtual_host": "d11.ddev.site"
    }
  },

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 8, 2024

Could you please check test coverage?

What do you mean, adding test? All tests passed and this is just presentation logic.

Could you take a look at the "All URLs" and see if it might be possible to do something similar there? It's the exact same class of problem. Not trying to expand scope, but it does look like exactly the same problem. (The label is also ambigous, it's really just showing the primary http and https ports for the webserver.)

I don't mind, but what do you have in mind? It's not the same problem because as you said what it's showing is at least clear enough. If I were to suggest something it could be:

  • Remove it altogether as the main urls are shown on each section anyway.
  • Change it to something Summary, or even leave All URLs but show a list with only the https versions of the sites with the domains. I wonder how many use it without https and with 127.0.0.1.

I was checking a bit at the logic and saw the alternatives to with and without router and with and without http, but I would just show either based on that same logic rather than showing all. Further more I think (haven't looked properly) that the url that is shown on the section will change depending on those factors already, so again, I wonder if All URLs is necessary.

@rfay
Copy link
Member

rfay commented Nov 8, 2024

What do you mean, adding test? All tests passed and this is just presentation logic.

See if TestCmdDescribe can be slightly improved to check this usage. Or consider it. I'm not insisting. "this is just presentation logic" -- well, all of ddev describe is presentation :)

I don't mind, but what do you have in mind? It's not the same problem because as you said what it's showing is at least clear enough. If I were to suggest something it could be:

Remove it altogether as the main urls are shown on each section anyway.
Change it to something Summary, or even leave All URLs but show a list with only the https versions of the sites with the domains. I wonder how many use it without https and with 127.0.0.1.

The router logic is quite different, this info can't be removed, it is not covered in each section. The "All URLs" has both by-URL and by-IP URLs, and they're unrelated to the ones in the web section, because they show what the router is doing, and that's the normal situation.

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 8, 2024

Fixed the json-output bit, will check on the rest later, not sure on the all urls, maybe separate it on a separate issue? but will check.

@rfay
Copy link
Member

rfay commented Nov 8, 2024

The other great and obscure thing here is it makes that second column possibly shorter, resulting in less wrapping on smaller terminals.

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 8, 2024

Not that obscure, it was part of what bothered me as well, it's the first bullet point in the PR summary :)

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 9, 2024

  • Added test coverage

Could you take a look at the "All URLs" and see if it might be possible to do something similar there? It's the exact same class of problem. Not trying to expand scope, but it does look like exactly the same problem. (The label is also ambigous, it's really just showing the primary http and https ports for the webserver.)

I changed All URLs for Project URLs, found it less missleading.. but we can not do that. Regardless I would do any further work on that, if any, on a separate issue.

@rfay question on testings.. The tests pass locally if I run make testcmd TESTARGS="-run TestCmdDescribe"

However, on Go Land it fails and I noticed the output is the previous version, like it's not using the built ddev but rather my local one?

@rfay
Copy link
Member

rfay commented Nov 9, 2024

The tests in the cmd directory most often use the ddev in the path, yours is probably not this one. Docs have this case,
https://ddev.readthedocs.io/en/stable/developers/building-contributing/#testing

To run a test (in the cmd package) against a individually-compiled DDEV binary, set the DDEV_BINARY_FULLPATH environment variable, for example DDEV_BINARY_FULLPATH=$PWD/.gotmp/bin/linux_amd64/ddev make testcmd.

Thanks for your work on this!

My normal working situation is I have a symlink in /usr/local/bin/ddev that normally points to my locally built version, but I use a script to point it to the homebrew version. So I'm almost always using the locally built version.

@hanoii hanoii requested a review from rfay November 9, 2024 19:18
Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Just took a quick look, and I like it, but changing the entire format of the ddev describe -j host_ports is a breaking change I would think. I know it wouldn't affect many people, but we try not to do that. I don't think it's parseable either.

 "host_ports": "33025->80, 33024->443, 5332->5222, 5555->5777, 32780->12445",

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 9, 2024 via email

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 9, 2024

Ah, there's no trailing comma, you just copy over a portion of it, right? What did you mean with it's not parseable?

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 9, 2024

Tests pass!

@rfay
Copy link
Member

rfay commented Nov 9, 2024

Sorry, I wasn't clear. This completely changes host_ports from a list of ports to a list of mappings. That's the problem, not trailing commas.

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 9, 2024

I understand.. well, your call here. I can go back to the previous version only for json output, or I can add a new element, host_ports_mapping and print that instead of that on the non json part.

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 9, 2024

        "host_ports": "32803,32804,32878,32879,32880,32881,32882,32883,32884,32885,32886,32887,32888,32889,32890,32891,32892,32893,32894,32895,32896,32897,32898,32899",
        "host_ports_mapping": "32803->80,32804->443,32878->4000,32879->30000,32880->30001,32881->30002,32882->30003,32883->30004,32884->30005,32885->30006,32886->30007,32887->30008,32888->30009,32889->30010,32890->30011,32891->30012,32892->30013,32893->30014,32894->30015,32895->30016,32896->30017,32897->30018,32898->30019,32899->30020",

@rfay
Copy link
Member

rfay commented Nov 9, 2024

host_ports_mapping is a great idea, but it should probably be a json map instead of plain text "->"

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 10, 2024

I started working on this, is this oK?:

        "host_ports_mapping": [
          {
            "exposed_port": "80",
            "host_port": "32803"
          },
          {
            "exposed_port": "443",
            "host_port": "32804"
          },
          {
            "exposed_port": "4000",
            "host_port": "32878"
          },
          {
            "exposed_port": "30000",
            "host_port": "32879"
          },

And also, something I should mention that maybe you missed and just to make sure you are OK with it is that I also changed the content of exposed_ports.. previously it included the ones that are also exported to the host, now I am only shoing those that are not "only" exposed in the container. A mapped port to the port is always exposed in the contianer as well obviously. That was my reasoning. So one option is that you are ok with it and we leave it like that, or I can leave exposed ports for json the same way as before and do some extra logic on the table to remove them.

@rfay
Copy link
Member

rfay commented Nov 10, 2024

I definitely like that for host_ports_mapping. Will look closely when I test at exposed_ports.

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 10, 2024

Worked on this

@hanoii hanoii requested a review from rfay November 10, 2024 22:29
@hanoii hanoii force-pushed the improve-describe-exposed-ports branch from 6bbfd10 to b276765 Compare November 10, 2024 22:41
@hanoii
Copy link
Collaborator Author

hanoii commented Nov 10, 2024

well, not sure why the static validation is failing. seems something completely out of this PR.

EDIT: works locally with make staticrequired

@rfay
Copy link
Member

rfay commented Nov 11, 2024

I think you don't have the latest golangci-lint, you'll probably get the same results then. Newest is 1.62.0. I had 1.61.0. Annoyingly they keep "improving" its behavior over time :)

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 15, 2024

Or:

InDocker <- Host:
  - web:80 <- 127.0.0.1:33041
  - web:443 <- 127.0.0.1:33042
  - web:8025

@rfay
Copy link
Member

rfay commented Nov 15, 2024

Oh, those are improving things significantly! I like

https://a.ddev.site       
InDocker -> Host:
  - web:80 -> 127.0.0.1:33041
  - web:443 -> 127.0.0.1:33042
  - web:8025

quite a lot. And now it's not just providing information, it's providing context. I can go with this. Try not to break the json version.

Now if we could explain to people what's going on with the router too. Not sure they'll ever understand. (out of scope)

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 15, 2024

You prefer -> to <-? The latter is more semantically correct :)

json will remain the same as before (I need to fix this)

@rfay
Copy link
Member

rfay commented Nov 15, 2024

You prefer -> to <-? The latter is more semantically correct :)

Well, that depends on which way you're looking at the traffic!

- web:80 -> 127.0.0.1:33041 seems to imply to me that port 80 is connected to 33041. Also, people are annoyed by backward arrows :)

@hanoii hanoii force-pushed the improve-describe-exposed-ports branch from 3821983 to c1078b3 Compare November 15, 2024 17:27
@hanoii
Copy link
Collaborator Author

hanoii commented Nov 15, 2024

Ok, I think this should be OK, I also expanded tests further:

Bare php project

┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Project: a /tmp/a https://a.ddev.site                                                                        │
│ Docker platform: orbstack                                                                                    │
│ Router: traefik                                                                                              │
├──────────────┬──────┬───────────────────────────────────────────────────────────────────┬────────────────────┤
│ SERVICE      │ STAT │ URL/PORT                                                          │ INFO               │
├──────────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ web          │ OK   │ https://a.ddev.site                                               │ php PHP8.2         │
│              │      │ InDocker -> Host:                                                 │ nginx-fpm          │
│              │      │  - web:80 -> 127.0.0.1:33041                                      │ docroot:''         │
│              │      │  - web:443 -> 127.0.0.1:33042                                     │ Perf mode: mutagen │
│              │      │  - web:8025                                                       │ NodeJS:20          │
├──────────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ db           │ OK   │ InDocker -> Host:                                                 │ mariadb:10.11      │
│              │      │  - db:3306 -> 127.0.0.1:33040                                     │ User/Pass: 'db/db' │
│              │      │                                                                   │ or 'root/root'     │
├──────────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ Mailpit      │      │ Mailpit: https://a.ddev.site:8026                                 │                    │
│              │      │ Launch: ddev mailpit                                              │                    │
├──────────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ Project URLs │      │ https://a.ddev.site, https://127.0.0.1:33042, http://a.ddev.site, │                    │
│              │      │ http://127.0.0.1:33041                                            │                    │
└──────────────┴──────┴───────────────────────────────────────────────────────────────────┴────────────────────┘

json

{
  "level": "info",
  "msg": "┌──────────────────────────────────────────────────────────────────────────────┐\n│ Project: a /tmp/a https://a.ddev.site                                        │\n│ Docker platform: orbstack                                                    │\n│ Router: traefik                                                              │\n├──────────────┬──────┬───────────────────────────────────┬────────────────────┤\n│ SERVICE      │ STAT │ URL/PORT                          │ INFO               │\n├──────────────┼──────┼───────────────────────────────────┼────────────────────┤\n│ web          │ \u001b[32mOK\u001b[0m   │ https://a.ddev.site               │ php PHP8.2         │\n│              │      │ InDocker -> Host:                 │ nginx-fpm          │\n│              │      │  - web:80 -> 127.0.0.1:33077      │ docroot:''         │\n│              │      │  - web:443 -> 127.0.0.1:33078     │ Perf mode: mutagen │\n│              │      │  - web:8025                       │ NodeJS:20          │\n├──────────────┼──────┼───────────────────────────────────┼────────────────────┤\n│ db           │ \u001b[32mOK\u001b[0m   │ InDocker -> Host:                 │ mariadb:10.11      │\n│              │      │  - db:3306 -> 127.0.0.1:33076     │ User/Pass: 'db/db' │\n│              │      │                                   │ or 'root/root'     │\n├──────────────┼──────┼───────────────────────────────────┼────────────────────┤\n│ busybox      │ \u001b[32mOK\u001b[0m   │ InDocker:                         │                    │\n│              │      │  - busybox:6594                   │                    │\n├──────────────┼──────┼───────────────────────────────────┼────────────────────┤\n│ Mailpit      │      │ Mailpit: https://a.ddev.site:8026 │                    │\n│              │      │ Launch: ddev mailpit              │                    │\n├──────────────┼──────┼───────────────────────────────────┼────────────────────┤\n│ Project URLs │      │ https://a.ddev.site,              │                    │\n│              │      │ https://127.0.0.1:33078,          │                    │\n│              │      │ http://a.ddev.site,               │                    │\n│              │      │ http://127.0.0.1:33077            │                    │\n└──────────────┴──────┴───────────────────────────────────┴────────────────────┘\n",
  "raw": {
    "approot": "/tmp/a",
    "database_type": "mariadb",
    "database_version": "10.11",
    "dbimg": "ddev/ddev-dbserver-mariadb-10.11:20241109_use_bin_env",
    "dbinfo": {
      "database_type": "mariadb",
      "database_version": "10.11",
      "dbPort": "3306",
      "dbname": "db",
      "host": "db",
      "password": "db",
      "published_port": 33076,
      "username": "db"
    },
    "docroot": "",
    "fail_on_hook_fail": false,
    "hostname": "a.ddev.site",
    "hostnames": [
      "a.ddev.site"
    ],
    "httpURLs": [
      "http://a.ddev.site",
      "http://127.0.0.1:33077"
    ],
    "httpsURLs": [
      "https://a.ddev.site",
      "https://127.0.0.1:33078"
    ],
    "httpsurl": "https://a.ddev.site",
    "httpurl": "http://a.ddev.site",
    "mailpit_https_url": "https://a.ddev.site:8026",
    "mailpit_url": "http://a.ddev.site:8025",
    "mutagen_enabled": true,
    "mutagen_status": "ok",
    "name": "a",
    "nodejs_version": "20",
    "performance_mode": "mutagen",
    "php_version": "8.2",
    "primary_url": "https://a.ddev.site",
    "router": "traefik",
    "router_disabled": false,
    "router_http_port": "80",
    "router_https_port": "443",
    "router_status": "healthy",
    "router_status_log": "container was previously healthy, so sleeping 59 seconds before continuing healthcheck...  OKhealthy",
    "services": {
      "busybox": {
        "exposed_ports": "6594",
        "full_name": "ddev-a-busybox",
        "host_ports": "",
        "host_ports_mapping": [],
        "image": "busybox",
        "short_name": "busybox",
        "status": "running"
      },
      "db": {
        "exposed_ports": "3306",
        "full_name": "ddev-a-db",
        "host_ports": "33076",
        "host_ports_mapping": [
          {
            "exposed_port": "3306",
            "host_port": "33076"
          }
        ],
        "image": "ddev/ddev-dbserver-mariadb-10.11:v1.23.5",
        "short_name": "db",
        "status": "running"
      },
      "web": {
        "exposed_ports": "80,443,8025",
        "full_name": "ddev-a-web",
        "host_http_url": "http://127.0.0.1:33077",
        "host_https_url": "https://127.0.0.1:33078",
        "host_ports": "33077,33078",
        "host_ports_mapping": [
          {
            "exposed_port": "80",
            "host_port": "33077"
          },
          {
            "exposed_port": "443",
            "host_port": "33078"
          }
        ],
        "http_url": "http://a.ddev.site",
        "https_url": "https://a.ddev.site",
        "image": "ddev/ddev-webserver:v1.23.5",
        "short_name": "web",
        "status": "running",
        "virtual_host": "a.ddev.site"
      }
    },
    "shortroot": "/tmp/a",
    "ssh_agent_status": "healthy",
    "status": "running",
    "status_desc": "running",
    "type": "php",
    "urls": [
      "https://a.ddev.site",
      "https://127.0.0.1:33078",
      "http://a.ddev.site",
      "http://127.0.0.1:33077"
    ],
    "webimg": "ddev/ddev-webserver:20241111_stasadev_n_install_cleanup",
    "webserver_type": "nginx-fpm",
    "xdebug_enabled": false
  },
  "time": "2024-11-15T15:12:31-03:00"
}

My project with a lot of ports

──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Project: project1 ~/Sites/subsite1/project1 https://project1.ddev.site                                       │
│ Docker platform: orbstack                                                                                    │
│ Router: traefik                                                                                              │
├──────────────┬──────┬───────────────────────────────────────────────────────────────────┬────────────────────┤
│ SERVICE      │ STAT │ URL/PORT                                                          │ INFO               │
├──────────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ web          │ OK   │ https://project1.ddev.site                                        │ drupal10 PHP8.2    │
│              │      │ InDocker -> Host:                                                 │ nginx-fpm          │
│              │      │  - web:80 -> 127.0.0.1:33008                                      │ docroot:'web'      │
│              │      │  - web:443 -> 127.0.0.1:33009                                     │ Perf mode: mutagen │
│              │      │  - web:4000 -> 127.0.0.1:32981                                    │ NodeJS:18.18.2     │
│              │      │  - web:8025                                                       │                    │
│              │      │  - web:30000 -> 127.0.0.1:32982                                   │                    │
│              │      │  - web:30001 -> 127.0.0.1:32983                                   │                    │
│              │      │  - web:30002 -> 127.0.0.1:32984                                   │                    │
│              │      │  - web:30003 -> 127.0.0.1:32985                                   │                    │
│              │      │  - web:30004 -> 127.0.0.1:32986                                   │                    │
│              │      │  - web:30005 -> 127.0.0.1:32987                                   │                    │
│              │      │  - web:30006 -> 127.0.0.1:32988                                   │                    │
│              │      │  - web:30007 -> 127.0.0.1:32989                                   │                    │
│              │      │  - web:30008 -> 127.0.0.1:32990                                   │                    │
│              │      │  - web:30009 -> 127.0.0.1:32991                                   │                    │
│              │      │  - web:30010 -> 127.0.0.1:32992                                   │                    │
│              │      │  - web:30011 -> 127.0.0.1:32993                                   │                    │
│              │      │  - web:30012 -> 127.0.0.1:32994                                   │                    │
│              │      │  - web:30013 -> 127.0.0.1:32995                                   │                    │
│              │      │  - web:30014 -> 127.0.0.1:32996                                   │                    │
│              │      │  - web:30015 -> 127.0.0.1:32997                                   │                    │
│              │      │  - web:30016 -> 127.0.0.1:32998                                   │                    │
│              │      │  - web:30017 -> 127.0.0.1:32999                                   │                    │
│              │      │  - web:30018 -> 127.0.0.1:33000                                   │                    │
│              │      │  - web:30019 -> 127.0.0.1:33001                                   │                    │
│              │      │  - web:30020 -> 127.0.0.1:33004                                   │                    │
├──────────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ db           │ OK   │ InDocker -> Host:                                                 │ mariadb:10.11      │
│              │      │  - db:3306 -> 127.0.0.1:33007                                     │ User/Pass: 'db/db' │
│              │      │                                                                   │ or 'root/root'     │
├──────────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ Mailpit      │      │ Mailpit: https://project1.ddev.site:8026                          │                    │
│              │      │ Launch: ddev mailpit                                              │                    │
├──────────────┼──────┼───────────────────────────────────────────────────────────────────┼────────────────────┤
│ Project URLs │      │ https://project1.ddev.site, https://*.project1.ddev.site,         │                    │
│              │      │ https://127.0.0.1:33009, http://project1.ddev.site,               │                    │
│              │      │ http://*.project1.ddev.site, http://127.0.0.1:33008               │                    │
└──────────────┴──────┴───────────────────────────────────────────────────────────────────┴────────────────────┘

json:

{
  "level": "info",
  "msg": "┌─────────────────────────────────────────────────────────────────────────────────────┐\n│ Project: project1 ~/Sites/subsite1/project1 https://project1.ddev.site              │\n│ Docker platform: orbstack                                                           │\n│ Router: traefik                                                                     │\n├──────────────┬──────┬──────────────────────────────────────────┬────────────────────┤\n│ SERVICE      │ STAT │ URL/PORT                                 │ INFO               │\n├──────────────┼──────┼──────────────────────────────────────────┼────────────────────┤\n│ web          │ \u001b[32mOK\u001b[0m   │ https://project1.ddev.site               │ drupal10 PHP8.2    │\n│              │      │ InDocker -> Host:                        │ nginx-fpm          │\n│              │      │  - web:80 -> 127.0.0.1:33008             │ docroot:'web'      │\n│              │      │  - web:443 -> 127.0.0.1:33009            │ Perf mode: mutagen │\n│              │      │  - web:4000 -> 127.0.0.1:32981           │ NodeJS:18.18.2     │\n│              │      │  - web:8025                              │                    │\n│              │      │  - web:30000 -> 127.0.0.1:32982          │                    │\n│              │      │  - web:30001 -> 127.0.0.1:32983          │                    │\n│              │      │  - web:30002 -> 127.0.0.1:32984          │                    │\n│              │      │  - web:30003 -> 127.0.0.1:32985          │                    │\n│              │      │  - web:30004 -> 127.0.0.1:32986          │                    │\n│              │      │  - web:30005 -> 127.0.0.1:32987          │                    │\n│              │      │  - web:30006 -> 127.0.0.1:32988          │                    │\n│              │      │  - web:30007 -> 127.0.0.1:32989          │                    │\n│              │      │  - web:30008 -> 127.0.0.1:32990          │                    │\n│              │      │  - web:30009 -> 127.0.0.1:32991          │                    │\n│              │      │  - web:30010 -> 127.0.0.1:32992          │                    │\n│              │      │  - web:30011 -> 127.0.0.1:32993          │                    │\n│              │      │  - web:30012 -> 127.0.0.1:32994          │                    │\n│              │      │  - web:30013 -> 127.0.0.1:32995          │                    │\n│              │      │  - web:30014 -> 127.0.0.1:32996          │                    │\n│              │      │  - web:30015 -> 127.0.0.1:32997          │                    │\n│              │      │  - web:30016 -> 127.0.0.1:32998          │                    │\n│              │      │  - web:30017 -> 127.0.0.1:32999          │                    │\n│              │      │  - web:30018 -> 127.0.0.1:33000          │                    │\n│              │      │  - web:30019 -> 127.0.0.1:33001          │                    │\n│              │      │  - web:30020 -> 127.0.0.1:33004          │                    │\n├──────────────┼──────┼──────────────────────────────────────────┼────────────────────┤\n│ db           │ \u001b[32mOK\u001b[0m   │ InDocker -> Host:                        │ mariadb:10.11      │\n│              │      │  - db:3306 -> 127.0.0.1:33007            │ User/Pass: 'db/db' │\n│              │      │                                          │ or 'root/root'     │\n├──────────────┼──────┼──────────────────────────────────────────┼────────────────────┤\n│ Mailpit      │      │ Mailpit: https://project1.ddev.site:8026 │                    │\n│              │      │ Launch: ddev mailpit                     │                    │\n├──────────────┼──────┼──────────────────────────────────────────┼────────────────────┤\n│ Project URLs │      │ https://project1.ddev.site,              │                    │\n│              │      │ https://*.project1.ddev.site,            │                    │\n│              │      │ https://127.0.0.1:33009,                 │                    │\n│              │      │ http://project1.ddev.site,               │                    │\n│              │      │ http://*.project1.ddev.site,             │                    │\n│              │      │ http://127.0.0.1:33008                   │                    │\n└──────────────┴──────┴──────────────────────────────────────────┴────────────────────┘\n",
  "raw": {
    "approot": "/Users/ariel/Sites/subsite1/project1",
    "database_type": "mariadb",
    "database_version": "10.11",
    "dbimg": "ddev/ddev-dbserver-mariadb-10.11:20241109_use_bin_env",
    "dbinfo": {
      "database_type": "mariadb",
      "database_version": "10.11",
      "dbPort": "3306",
      "dbname": "db",
      "host": "db",
      "password": "db",
      "published_port": 33007,
      "username": "db"
    },
    "docroot": "web",
    "fail_on_hook_fail": true,
    "hostname": "project1.ddev.site",
    "hostnames": [
      "project1.ddev.site",
      "*.project1.ddev.site"
    ],
    "httpURLs": [
      "http://project1.ddev.site",
      "http://*.project1.ddev.site",
      "http://127.0.0.1:33008"
    ],
    "httpsURLs": [
      "https://project1.ddev.site",
      "https://*.project1.ddev.site",
      "https://127.0.0.1:33009"
    ],
    "httpsurl": "https://project1.ddev.site",
    "httpurl": "http://project1.ddev.site",
    "mailpit_https_url": "https://project1.ddev.site:8026",
    "mailpit_url": "http://project1.ddev.site:8025",
    "mutagen_enabled": true,
    "mutagen_status": "ok",
    "name": "project1",
    "nodejs_version": "18.18.2",
    "performance_mode": "mutagen",
    "php_version": "8.2",
    "primary_url": "https://project1.ddev.site",
    "router": "traefik",
    "router_disabled": false,
    "router_http_port": "80",
    "router_https_port": "443",
    "router_status": "healthy",
    "router_status_log": "container was previously healthy, so sleeping 59 seconds before continuing healthcheck...  OKhealthy",
    "services": {
      "db": {
        "exposed_ports": "3306",
        "full_name": "ddev-project1-db",
        "host_ports": "33007",
        "host_ports_mapping": [
          {
            "exposed_port": "3306",
            "host_port": "33007"
          }
        ],
        "image": "ddev/ddev-dbserver-mariadb-10.11:v1.23.5",
        "short_name": "db",
        "status": "running"
      },
      "web": {
        "exposed_ports": "80,443,4000,8025,30000,30001,30002,30003,30004,30005,30006,30007,30008,30009,30010,30011,30012,30013,30014,30015,30016,30017,30018,30019,30020",
        "full_name": "ddev-project1-web",
        "host_http_url": "http://127.0.0.1:33008",
        "host_https_url": "https://127.0.0.1:33009",
        "host_ports": "33008,33009,32981,32982,32983,32984,32985,32986,32987,32988,32989,32990,32991,32992,32993,32994,32995,32996,32997,32998,32999,33000,33001,33004",
        "host_ports_mapping": [
          {
            "exposed_port": "80",
            "host_port": "33008"
          },
          {
            "exposed_port": "443",
            "host_port": "33009"
          },
          {
            "exposed_port": "4000",
            "host_port": "32981"
          },
          {
            "exposed_port": "30000",
            "host_port": "32982"
          },
          {
            "exposed_port": "30001",
            "host_port": "32983"
          },
          {
            "exposed_port": "30002",
            "host_port": "32984"
          },
          {
            "exposed_port": "30003",
            "host_port": "32985"
          },
          {
            "exposed_port": "30004",
            "host_port": "32986"
          },
          {
            "exposed_port": "30005",
            "host_port": "32987"
          },
          {
            "exposed_port": "30006",
            "host_port": "32988"
          },
          {
            "exposed_port": "30007",
            "host_port": "32989"
          },
          {
            "exposed_port": "30008",
            "host_port": "32990"
          },
          {
            "exposed_port": "30009",
            "host_port": "32991"
          },
          {
            "exposed_port": "30010",
            "host_port": "32992"
          },
          {
            "exposed_port": "30011",
            "host_port": "32993"
          },
          {
            "exposed_port": "30012",
            "host_port": "32994"
          },
          {
            "exposed_port": "30013",
            "host_port": "32995"
          },
          {
            "exposed_port": "30014",
            "host_port": "32996"
          },
          {
            "exposed_port": "30015",
            "host_port": "32997"
          },
          {
            "exposed_port": "30016",
            "host_port": "32998"
          },
          {
            "exposed_port": "30017",
            "host_port": "32999"
          },
          {
            "exposed_port": "30018",
            "host_port": "33000"
          },
          {
            "exposed_port": "30019",
            "host_port": "33001"
          },
          {
            "exposed_port": "30020",
            "host_port": "33004"
          }
        ],
        "http_url": "http://project1.ddev.site",
        "https_url": "https://project1.ddev.site",
        "image": "ddev/ddev-webserver:v1.23.5",
        "short_name": "web",
        "status": "running",
        "virtual_host": "project1.ddev.site"
      }
    },
    "shortroot": "~/Sites/subsite1/project1",
    "ssh_agent_status": "healthy",
    "status": "running",
    "status_desc": "running",
    "type": "drupal10",
    "urls": [
      "https://project1.ddev.site",
      "https://*.project1.ddev.site",
      "https://127.0.0.1:33009",
      "http://project1.ddev.site",
      "http://*.project1.ddev.site",
      "http://127.0.0.1:33008"
    ],
    "webimg": "ddev/ddev-webserver:20241111_stasadev_n_install_cleanup",
    "webserver_type": "nginx-fpm",
    "xdebug_enabled": false
  },
  "time": "2024-11-15T15:10:16-03:00"
}

@hanoii hanoii requested a review from rfay November 15, 2024 18:14
@hanoii
Copy link
Collaborator Author

hanoii commented Nov 15, 2024

I am curious on how many people use ddev st -j, do you have any stats on that?

@rfay
Copy link
Member

rfay commented Nov 15, 2024

I am curious on how many people use ddev st -j, do you have any stats on that?

No stats, I imagine it's few. Mostly probably wrapped in scripts that determine things about a project. There have been a few of those tossed around over the years.

Copy link
Member

@stasadev stasadev left a comment

Choose a reason for hiding this comment

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

Looks great, even better!

And if it matters, I noticed that host_ports are not sorted:

Tested with config from #6699 (review)

$ ddev st -j | jq .raw.services.phpmyadmin | grep 'ports"'
  "exposed_ports": "80,5000,5605,8983,12345,14556",
  "host_ports": "5000,5001,1234",

$ ddev st -j | jq .raw.services.web | grep 'ports"'
  "exposed_ports": "80,443,3000,5222,5492,5777,8025,12394,12445,57497",
  "host_ports": "32866,32867,5332,5555,32770",

$ ddev st -j | jq .raw.services.db | grep 'ports"'
  "exposed_ports": "3306,3999,4352,6594,54355",
  "host_ports": "32863,12312,32768",

@hanoii
Copy link
Collaborator Author

hanoii commented Nov 18, 2024

And if it matters, I noticed that host_ports are not sorted:

it mattered.. fixed that and added testing for being sorted.

@hanoii hanoii requested a review from stasadev November 18, 2024 22:55
@hanoii hanoii force-pushed the improve-describe-exposed-ports branch from 7b81f2e to 7881a3e Compare November 18, 2024 22:55
@hanoii
Copy link
Collaborator Author

hanoii commented Nov 18, 2024

rebased

@rfay
Copy link
Member

rfay commented Nov 19, 2024

@stasadev mentioned in our meeting today how absolutely thrilled he is with this ❤️

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

It's great! Thanks for this marvelous contribution!

@@ -0,0 +1,33 @@
services:
Copy link
Member

Choose a reason for hiding this comment

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

Just a note that docker-compose.override.yaml doesn't really have any use in DDEV (but it works here just fine, like any other docker-compose.*.yaml). Just docker-compose.something.yaml is more descriptive, merged in alpha order. Since DDEV loads all the docker-compose.*.yaml the "override" isn't really useful. I'm going to remove the reference from the docs. But... https://docs.docker.com/compose/how-tos/multiple-compose-files/merge/

@rfay rfay merged commit 2d90a7e into ddev:master Nov 19, 2024
17 checks passed
@hanoii hanoii deleted the improve-describe-exposed-ports branch November 19, 2024 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants