DOCROOT_SUBDIR not set, causing reinstall of Drupal files every start
Closed this issue · 6 comments
Using Drupal 8, in /usr/local/bin/init.sh there is a test to see if Drupal is installed by looking for
However, the DRUPAL_ROOT variable is wrong - it is the same as APP_ROOT and does not include "/web" at the end, which means ever time the container is started the files are copied again (which then causes a bad configuration and the container to fails).
This appears to be caused by DOCROOT_SUBDIR being empty when drupal-php.mk is executing, which defaults the path to "${APP_ROOT}". It appears that DOCROOT_SUBDIR should contain "web" but I don't see anything that sets that. I do see in a recent change to Dockerfile that DOCROOT_SUBDIR is set to a path including "web", but I confirmed that is being overwritten by the test in drupal-php.mk.
The workaround I am doing for now is to bash into my root_php_1 container and edit the /usr/local/bin/drupal-php.mk file. Here is what it currently contains:
ifeq ("$(DOCROOT_SUBDIR)", "")
DRUPAL_ROOT=$(APP_ROOT)/web <-- this is the hack that stops the reinstall
else
DRUPAL_ROOT="$(APP_ROOT)/$(DOCROOT_SUBDIR)"
endif
If I add a test for DRUPAL_ROOT being empty (which it isn't, thanks to Dockerfile) then it works fine:
ifeq ("$(DRUPAL_ROOT)", "")
ifeq ("$(DOCROOT_SUBDIR)", "")
DRUPAL_ROOT=$(APP_ROOT)
else
DRUPAL_ROOT="$(APP_ROOT)/$(DOCROOT_SUBDIR)"
endif
endif
I think this means one of two things: either add DOCROOT_SUBDIR to Dockerfile, or change drupal-php.mk to no longer overwrite DRUPAL_ROOT based on DOCROOT_SUBDIR alone.
Appreciate the help!
Chris
Thanks for reporting this, we should probably add the environment variable DOCROOT_SUBDIR
to the docker4drupal's compose file, web
should not be hardcoded.
Actually, DRUPAL_ROOT
is hard coded in Dockerfile for this image so everything should work fine. Maybe you're just using an outdated version?
Correct - DRUPAL_ROOT is in Dockerfile. However, in drupal-php.mk it ignores DRUPAL_ROOT and instead looks at DOCROOT_SUBDIR and based on it (which is empty) it overrides the DRUPAL_ROOT value (to no longer include "web"). I think what is needed is for DOCROOT_SUBDIR to be set to "web" in Dockerfile, or for drupal-php.mk to be changed to not override DRUPAL_ROOT.
What actions do you use from drupal-php.mk
? Normally, this image uses only init action in docker4drupal setup.
It is part of init, which triggers the .PHONY build (via the dependency on init-drupal) and that is where this change happens.
I'm just using simple, normal usage (no custom changes) and experience this problem. Here are the steps I use:
- I clear out my images and volumes to start fresh, or simply start a brand new server (I've done both many times)
- I download and run (docker-compose up -d)
- Visit the web site and finish the startup wizard
- Shut down the containers (docker-compose stop)
- Start the containers (docker-compose start)
At this point, the container root_php_1 will fail to stay running and logs will show that it copied the Drupal files over again (due to the .PHONY dependency overwriting DRUPAL_ROOT).
Thank you for details. This issue has been fixed, latest images contain the fix.