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:
|
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:
|
'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:
Steps to reproduce:
composer server shellwpError: 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_NAMEandCOMPOSE_PROJECT_TLD:altis-local-server/inc/namespace.php
Lines 40 to 42 in cdf079c
However, the latter is not defined, so we get a trailing
.Worse,
COMPOSE_PROJECT_NAMEis inconsistent; usually, it refers only to the subdomain:altis-local-server/inc/composer/class-command.php
Lines 203 to 204 in cdf079c
However, the docker-compose configuration instead sets this to the full domain:
altis-local-server/inc/composer/class-docker-compose-generator.php
Line 169 in cdf079c
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
envinsidecomposer server shell)We also need to fix the
HTTP_HOSToverride, as if we're in Codespaces, the TLD is not set at all.COMPOSE_PROJECT_NAMEseems 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_NAMEhas an existing specific purpose.Acceptance criteria:
COMPOSE_PROJECT_NAMEcontains only the docker-compose project nameCOMPOSE_PROJECT_TLDcontains the TLD inside the shellALTIS_DEFAULT_HOSTcontains the defaultHTTP_HOSTwpwith no--urlparameter inside the shell usesALTIS_DEFAULT_HOSTcorrectly