Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Cannot run npm install from container #31

Open
derekherman opened this issue Dec 12, 2019 · 1 comment · May be fixed by #34
Open

Cannot run npm install from container #31

derekherman opened this issue Dec 12, 2019 · 1 comment · May be fixed by #34
Labels
bug Something isn't working

Comments

@derekherman
Copy link
Contributor

If you run npm run docker -- npm install from the container then you will get an error when composer tries to run.

npm WARN lifecycle @xwp/block-scaffolding-wp@1.0.0~postinstall: cannot run in wd @xwp/block-scaffolding-wp@1.0.0 composer install (wd=/var/www/html/wp-content/plugins/block-scaffolding-wp)

Basically, NPM tries to downgrade its privileges when it runs scripts. So you have to actually run it like so:

npm run docker -- npm install --unsafe-perm

@kasparsd
Copy link
Contributor

This is because the WordPress apache image runs as root to be able to start the apache web server on container start (which calls apache2-foreground):

$ npm run docker -- whoami
root

Until we switch to our own images the solution is to specify the user in the docker wrapper script:

docker-compose run --user=1000 --workdir=/var/www/html/wp-content/plugins/block-scaffolding-wp wordpress

Since wp-content/plugins/block-scaffolding-wp wordpress is bind mounted to a local directory, the user should be the same as the local host user.

@kasparsd kasparsd linked a pull request Dec 13, 2019 that will close this issue
@kasparsd kasparsd added the bug Something isn't working label Dec 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants