postlight / headless-wp-starter

🔪 WordPress + React Starter Kit: Spin up a WordPress-powered React app in one step
https://archive.postlight.com/labs/wordpress-react-starter-kit
GNU General Public License v2.0
4.48k stars 649 forks source link

wp-headless is not work #202

Open JasonHJ opened 5 years ago

JasonHJ commented 5 years ago

After run : docker-compose up -d , I found the wp-headless is stoped, and The logs of wp-headless show : wp-headless | Waiting for MySQL.................................... wp-headless | Error: This does not seem to be a WordPress installation. wp-headless | Pass --path=path/to/wordpress or run wp core download. wp-headless | Error: '/var/www/html/' is not writable by current user. wp-headless | Error: This does not seem to be a WordPress installation.

Does anybody know what this is about, Many thanks

modelm commented 5 years ago

Is this a brand new install? Can you provide more details like your OS and docker environment? Try rebuilding your wp-headless container:

docker-compose up --build --force-recreate wp-headless

tinyherocarrot commented 5 years ago

@modelm I was also having issues with wp-headless and this worked perfectly! Thank you for the tip 😄

JensvdHeydt commented 5 years ago

I'm having the exact same problem. It looks like the folder /var/www/ isn't writeable during the initial install. Running the "--force-recreate" did the trick but still it looks like something is wrong here.

JensvdHeydt commented 5 years ago

The frontend-container has similar problems:

frontend | Error: EACCES: permission denied, rmdir '/home/node/app/.next' frontend | error Command failed with exit code 1.

pepjo commented 5 years ago

docker-compose up --build --force-recreate wp-headless did not work for me :(

The full log is:

 docker-compose up --build --force-recreate wp-headless                                                                                                                                            13.3s  Tue 26 Mar 2019 20:34:39 GMT
Building wp-headless
Step 1/9 : FROM wordpress
 ---> 805ddf03fba3
Step 2/9 : RUN sed -i 's/80/8080/' /etc/apache2/ports.conf /etc/apache2/sites-enabled/000-default.conf
 ---> Using cache
 ---> dca4d628a031
Step 3/9 : RUN mv "$PHP_INI_DIR"/php.ini-development "$PHP_INI_DIR"/php.ini
 ---> Using cache
 ---> 8affd59125d1
Step 4/9 : RUN apt-get update;  apt-get install -yq mysql-client netcat sudo less git unzip
 ---> Using cache
 ---> 0dc9dc76ca41
Step 5/9 : RUN curl -sL https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -o wp;        chmod +x wp;    mv wp /usr/local/bin/;  mkdir /var/www/.wp-cli;         chown www-data:www-data /var/www/.wp-cli
 ---> Using cache
 ---> 08ff5d710111
Step 6/9 : RUN curl -sL https://raw.githubusercontent.com/composer/getcomposer.org/master/web/installer | php;  mv composer.phar /usr/local/bin/composer;       mkdir /var/www/.composer;       chown www-data:www-data /var/www/.composer
 ---> Using cache
 ---> 90986cf05891
Step 7/9 : RUN sudo -u www-data composer global require         phpunit/phpunit         dealerdirect/phpcodesniffer-composer-installer  phpcompatibility/phpcompatibility-wp    automattic/vipwpcs
 ---> Using cache
 ---> 9d68b1550f4f
Step 8/9 : ENV PATH="/var/www/.composer/vendor/bin:${PATH}"
 ---> Using cache
 ---> 0b29e8eb1e01
Step 9/9 : EXPOSE 8080
 ---> Using cache
 ---> 65f027afbeb4
Successfully built 65f027afbeb4
Successfully tagged headless-wp-starter_wp-headless:latest
Recreating db-headless ... done
Recreating wp-headless ... done
Attaching to wp-headless
wp-headless         | Error: This does not seem to be a WordPress installation.
wp-headless         | Pass --path=`path/to/wordpress` or run `wp core download`.
wp-headless         | Error: '/var/www/html/' is not writable by current user.
wp-headless exited with code 1
pepjo commented 5 years ago

Looks related to: https://github.com/10up/wp-local-docker/issues/17

kkerley commented 5 years ago

I'm having a similar issue running Ubuntu 18.04.

Successfully tagged headlesswpstarter_wp-headless:latest
WARNING: Image for service wp-headless was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Pulling frontend (node:latest)...
latest: Pulling from library/node
e79bb959ec00: Pull complete
d4b7902036fe: Pull complete
1b2a72d4e030: Pull complete
d54db43011fd: Pull complete
69d473365bb3: Pull complete
6e2490ee2dc8: Pull complete
374acee750f9: Pull complete
57b95309019b: Pull complete
Digest: sha256:83ff5b74b4af0c536daba824344f4ca2b1d18c7c69d3dc68d947a95bdaf987bf
Status: Downloaded newer image for node:latest
Creating frontend ... 
Creating db-headless ... 
Creating frontend-graphql ... 
Creating frontend
Creating frontend-graphql
Creating db-headless ... done
Creating wp-headless ... 
Creating wp-headless ... error

ERROR: for wp-headless  Cannot start service wp-headless: OCI runtime create failed: container_linux.go:345: starting container process caused "chdir to cwd (\"/var/www/html\") set in config.json failed: permission denied": unknown

ERROR: for wp-headless  Cannot start service wp-headless: OCI runtime create failed: container_linux.go:345: starting container process caused "chdir to cwd (\"/var/www/html\") set in config.json failed: permission denied": unknown
ERROR: Encountered errors while bringing up the project.

Using docker-compose up --build --force-recreate wp-headless did not work for me either.

shanebp commented 5 years ago

Using Linux Mint 19.1 Cinnamon 64-bit I get exactly the same results and errors as @kkerley

modelm commented 5 years ago

I don't have a linux host handy to test, but can someone please try https://github.com/postlight/headless-wp-starter/compare/fix-linux-chmod and see if that helps?

shanebp commented 5 years ago

@modelm

$ docker-compose up -d Removing wp-headless Recreating frontend-graphql ... Recreating frontend-graphql Recreating frontend ... Starting db-headless ... Recreating frontend Starting db-headless ... done Recreating a504963af019_wp-headless ... Recreating a504963af019_wp-headless ... error

ERROR: for a504963af019_wp-headless Cannot start service wp-headless: OCI runtime create failed: container_linux.go:345: starting container process caused "chdir to cwd (\"/var/www/html\") set in config.json failed: permission denied": unknown

ERROR: for frontend UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

ERROR: for frontend-graphql UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

ERROR: for wp-headless Cannot start service wp-headless: OCI runtime create failed: container_linux.go:345: starting container process caused "chdir to cwd (\"/var/www/html\") set in config.json failed: permission denied": unknown

ERROR: for frontend-graphql UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)

ERROR: for frontend UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60) ERROR: An HTTP request took too long to complete. Retry with --verbose to obtain debug information. If you encounter this issue regularly because of slow network conditions, consider setting COMPOSE_HTTP_TIMEOUT to a higher value (current value: 60).

shanebp commented 5 years ago

@modelm

$ docker-compose up --build --force-recreate wp-headless

ERROR: for a504963af019_a504963af019_wp-headless Cannot start service wp-headless: OCI runtime create failed: container_linux.go:345: starting container process caused "chdir to cwd (\"/var/www/html\") set in config.json failed: permission denied": unknown

ERROR: for wp-headless Cannot start service wp-headless: OCI runtime create failed: container_linux.go:345: starting container process caused "chdir to cwd (\"/var/www/html\") set in config.json failed: permission denied": unknown ERROR: Encountered errors while bringing up the project.

lightstrike commented 5 years ago

@modelm Tried the fix-linux-chmod branch on Linux Mint 18.3 Cinnamon 64-bit, running docker-compose up --build --force-recreate wp-headless:

Building wp-headless
Step 1/10 : FROM wordpress
 ---> 9451d745d1dd
Step 2/10 : RUN sed -i 's/80/8080/' /etc/apache2/ports.conf /etc/apache2/sites-enabled/000-default.conf
 ---> Using cache
 ---> b4cf9bf0c006
Step 3/10 : RUN mv "$PHP_INI_DIR"/php.ini-development "$PHP_INI_DIR"/php.ini
 ---> Using cache
 ---> 388fbcbffb57
Step 4/10 : RUN apt-get update;     apt-get install -yq mysql-client netcat sudo less git unzip
 ---> Using cache
 ---> 038f2a1ea71f
Step 5/10 : RUN curl -sL https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -o wp;   chmod +x wp;    mv wp /usr/local/bin/;  mkdir /var/www/.wp-cli;     chown www-data:www-data /var/www/.wp-cli
 ---> Using cache
 ---> dd6d7f01403c
Step 6/10 : RUN curl -sL https://raw.githubusercontent.com/composer/getcomposer.org/master/web/installer | php;     mv composer.phar /usr/local/bin/composer;   mkdir /var/www/.composer;   chown www-data:www-data /var/www/.composer
 ---> Using cache
 ---> bcc53cf3000a
Step 7/10 : RUN sudo -u www-data composer global require    phpunit/phpunit     dealerdirect/phpcodesniffer-composer-installer  phpcompatibility/phpcompatibility-wp    automattic/vipwpcs
 ---> Using cache
 ---> e747b3a8dc19
Step 8/10 : RUN chown -R www-data:www-data /var/www/html
 ---> Running in a8df7c06d2eb
Removing intermediate container a8df7c06d2eb
 ---> 75a595dee6f2
Step 9/10 : ENV PATH="/var/www/.composer/vendor/bin:${PATH}"
 ---> Running in 657f2070ba1b
Removing intermediate container 657f2070ba1b
 ---> 240d42baf899
Step 10/10 : EXPOSE 8080
 ---> Running in 532177b4e5c4
Removing intermediate container 532177b4e5c4
 ---> cf06c48ef60c
Successfully built cf06c48ef60c
Successfully tagged headlesswpstarter_wp-headless:latest
Recreating db-headless ... done
Recreating wp-headless ... done
Attaching to wp-headless
wp-headless         | Error: This does not seem to be a WordPress installation.
wp-headless         | Pass --path=`path/to/wordpress` or run `wp core download`.
wp-headless         | Error: '/var/www/html/' is not writable by current user.
wp-headless exited with code 1
jayb967 commented 5 years ago

I am having the same exact issue even after using docker-compose up --build --force-recreate wp-headless

jayb967 commented 5 years ago

I don't have a linux host handy to test, but can someone please try https://github.com/postlight/headless-wp-starter/compare/fix-linux-chmod and see if that helps?

Thanks this worked for me! Since pull request isn't committed, Just added RUN chown -R www-data:www-data /var/www/html in my Dockefile right above ENV PATH="/var/www/.composer/vendor/bin:${PATH}" just like the pr ..

eliasaj92 commented 5 years ago

fix-linux-chmod not working on ubuntu 19 either

kkerley commented 5 years ago

I added RUN chown -R www-data:www-data /var/www/html Right above ENV PATH="/var/www/.composer/vendor/bin:${PATH}" just like @jayb967 but got the same error. So then I tried docker-compose up --build --force-recreate wp-headless And for the briefest of seconds I thought it was going to work until it spit out the same error yet again.

Recreating 17a122d4e60a_17a122d4e60a_17a122d4e60a_wp-headless ... error

ERROR: for 17a122d4e60a_17a122d4e60a_17a122d4e60a_wp-headless  Cannot start service wp-headless: OCI runtime create failed: container_linux.go:345: starting container process caused "chdir to cwd (\"/var/www/html\") set in config.json failed: permission denied": unknown

ERROR: for wp-headless  Cannot start service wp-headless: OCI runtime create failed: container_linux.go:345: starting container process caused "chdir to cwd (\"/var/www/html\") set in config.json failed: permission denied": unknown
ERROR: Encountered errors while bringing up the project.
jayb967 commented 5 years ago

These were the steps I did on Ubuntu 18.04 and have been working on the last 5 fresh starts: Before running docker-compose up -d and after adding RUN chown -R www-data:www-data /var/www/html to Dockerfile: Set permission for Wordpress file sudo chown -R www-data:www-data <wordpressFileLocation>

cd into frontend folder and run "yarn" to create node_modules

Give node permission to write: chmod a+w frontend/node_modules/ Then if you are not root: sudo docker-compose up -d

Any errors: docker-compose up --build --force-recreate wp-headless

Maybe this can all be added to Dockerfile but I don't much experience with docker yet.

kkerley commented 5 years ago

I found this on Stackoverflow regarding using sudo in a Dockerfile. Seems like a lot of extra steps for something that shouldn't require sudo privleges at all.

shanebp commented 5 years ago

just fyi: this repo works great on Linux Mint Cinnamon: https://github.com/keen-studio/react-wp-rest

eliasaj92 commented 5 years ago

you definitely shouldn't need to put sudo in a Dockerfile. That is bad practice and a huge security compromise

jackbillstrom commented 5 years ago

@JasonHJ Did you manage to solve this one?

Currently at the same error, been wrapping my head around this all day.

OS: Ubuntu 19.04 Docker: Docker version 19.03.1, build 74b1e89

jackbillstrom commented 5 years ago

Okey so here is what I did to get wp-headless started, if you could look at the Docker-compose.yml.

To get Wordpress installing correctly, I just added this to the volume :rw, like this: ` volumes:

Thus, running the Frontend via yarn start because there is still some permissions error to be sorted out.

bsides commented 4 years ago

Confirming it doesn't work. Ubuntu 19.

curtisbelt commented 4 years ago

@modelm

Re: https://github.com/postlight/headless-wp-starter/compare/fix-linux-chmod

The original issue --

wp-headless | Error: '/var/www/html/' is not writable by current user.
wp-headless | Error: This does not seem to be a WordPress installation.

was something I experienced (I'm on Fedora 31) and your fix worked immediately for me. Perhaps it's not working for everyone but I'd go ahead and merge that in as a start?

Koli14 commented 4 years ago

I tried all the workarounds above, non of them worked. Then searched in the closed issues, and find this. I'm new to docker, so I (maybe unnecessarily) cleaned docker (containers, Images, Volumes), as found here. Then cloned the repo, changed the docker-compose file, line 23 to user: 1000:1000, run docker-compose up -d, waited 5 minutes, and it was working.

ebox86 commented 4 years ago

Any update on this? Still seems to be an issue. None of the suggested fixes worked for me and the merged in fix to the DockerFile is also not working for me.

anu-rock commented 4 years ago

@ebox86 I was facing the same issue. For me @Koli14's solution worked fine. That is, setting user: 1000:1000 in docker-compose.yml.

marty-mcgee commented 3 years ago

From @jayb967

These were the steps I did on Ubuntu 18.04 and have been working on the last 5 fresh starts: Before running docker-compose up -d and after adding RUN chown -R www-data:www-data /var/www/html to Dockerfile: Set permission for Wordpress file sudo chown -R www-data:www-data <wordpressFileLocation>

cd into frontend folder and run "yarn" to create node_modules

Give node permission to write: chmod a+w frontend/node_modules/ Then if you are not root: sudo docker-compose up -d

Any errors: docker-compose up --build --force-recreate wp-headless

Maybe this can all be added to Dockerfile but I don't much experience with docker yet.

This is the answer I was looking for. Also, I needed to set permissions on my whole code (this repository) to user www-data (not root), so that the user has all access to execute the code (copying into /var/www). Thanks so much!!

edvinpontuslarsson commented 3 years ago

I tried all the workarounds above, non of them worked. Then searched in the closed issues, and find this. I'm new to docker, so I (maybe unnecessarily) cleaned docker (containers, Images, Volumes), as found here. Then cloned the repo, changed the docker-compose file, line 23 to user: 1000:1000, run docker-compose up -d, waited 5 minutes, and it was working.

This worked for me too, although I had to put the numbers in '' like this: user: '1000:1000'

itsazzad commented 2 years ago

Any update?

montchr commented 2 years ago

I noticed that @itsazzad's question about the status of this issue was hidden from the thread, marked as "not helpful"... but I echo their concern, and would add that the response to this issue in general sends a huge red flag to me. Considering the severity of this issue and that the only responses from maintainers were posted in 2019, it sure seems to me like this project is not actively maintained.