-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Steps to reproduce:
- Run
composer server shell - Inside the container, run
wp - Observe
Error: Site 'your-project.altis.dev.' not found. Define DOMAIN_CURRENT_SITE in 'wp-config.php' or use--url=to override.
This occurs because we set the host name using COMPOSE_PROJECT_NAME and COMPOSE_PROJECT_TLD:
altis-local-server/inc/namespace.php
Lines 40 to 42 in cdf079c
| if ( empty( $_SERVER['HTTP_HOST'] ) ) { | |
| $_SERVER['HTTP_HOST'] = getenv( 'COMPOSE_PROJECT_NAME' ) . '.' . getenv( 'COMPOSE_PROJECT_TLD' ); | |
| } |
However, the latter is not defined, so we get a trailing .
Worse, COMPOSE_PROJECT_NAME is inconsistent; usually, it refers only to the subdomain:
altis-local-server/inc/composer/class-command.php
Lines 203 to 204 in cdf079c
| 'COMPOSE_PROJECT_NAME' => $this->get_project_subdomain(), | |
| 'COMPOSE_PROJECT_TLD' => $this->get_project_tld(), |
However, the docker-compose configuration instead sets this to the full domain:
| 'COMPOSE_PROJECT_NAME' => $this->hostname, |
These need to be made consistent; this probably should have been done in #341 and #465, but we missed it. (You can verify this by running env inside composer server shell)
We also need to fix the HTTP_HOST override, as if we're in Codespaces, the TLD is not set at all. COMPOSE_PROJECT_NAME seems to only be used in this code, so it should be fine to update this.
I would suggest we introduce a new environment variable instead of reusing this, since COMPOSE_PROJECT_NAME has an existing specific purpose.
Acceptance criteria:
-
COMPOSE_PROJECT_NAMEcontains only the docker-compose project name -
COMPOSE_PROJECT_TLDcontains the TLD inside the shell -
ALTIS_DEFAULT_HOSTcontains the defaultHTTP_HOST - Running
wpwith no--urlparameter inside the shell usesALTIS_DEFAULT_HOSTcorrectly