Closed radarsymphony closed 1 year ago
I'm not sure this actually needs to be performed but I see no harm with this being added and is a better practice.
If working inside the container via console you can get away with just typing wp-cli
as there is a bash function (cat /root/.bashrc
) which automatically changes working dir to NGINX_WEBROOT
. The container initialization routines also work within the NGINX_WEBROOT
, so shouldn't be throwing errors when firing.
Your addition adds a safety net. Thanks.
Tagged as 5.4.5
and credited to @radarsymphony
Thanks. I think your command runs as the nginx user on line 77, which does not use the /root/.bashrc
.
I tested this by appending the following to the bottom of the /root/.bashrc
:
alias test='echo "I am a test"'
I then sourced the file and ran: sudo -u ${NGINX_USER} test
Nothing.
[tiredofit/wordpress:5.4.2 16:11:33 /] $ sudo -u ${NGINX_USER} env
HOSTNAME=f5bee208836c
TERM=xterm
PS1=[tiredofit/wordpress:5.4.2 \t \w] $
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MAIL=/var/mail/nginx
LOGNAME=nginx
USER=nginx
HOME=/var/cache/nginx
SHELL=/sbin/nologin
SUDO_COMMAND=/usr/bin/env
SUDO_USER=root
SUDO_UID=0
SUDO_GID=0
What I am I missing that enables the nginx user to make use of your /root/.bashrc
when it runs the command on line 77?
It's a root shell - but wp-cli executes as NGINX_USER
Hi tiredofit,
I found another issue with
SITE_URL_UPDATE_MODE
. I discovered that I also needed to add the path to the webroot in order for the DB update to occur via thewp-cli find-replace
. After I added--path="${NGINX_WEBROOT}"
the command ran and the DB updated.