Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve permissions issues in the x-debug example #91

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions assets/php-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ listen = /var/run/php/php-fpm.sock
listen.owner = www-data
listen.group = www-data
;; ignored when FPM is not running as root
; user = www-data
; group = www-data
user = www-data
group = www-data

pm = dynamic
pm.max_children = 5
Expand Down
17 changes: 12 additions & 5 deletions assets/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ export DUMP_ON_RESTART="${DUMP_ON_RESTART:-false}"
export INIT_ON_RESTART="${INIT_ON_RESTART:-false}"
export INIT_SCRIPTS_DIR="${INIT_SCRIPTS_DIR:-/tmp/init-scripts/}"
export INIT_SCRIPTS_ON_RESTART="${INIT_SCRIPTS_ON_RESTART:-false}"
export INIT_SCRIPTS_USER="${INIT_SCRIPTS_USER:-www-data}"
export INIT_SCRIPTS_USER="${INIT_SCRIPTS_USER:-$RUN_AS_USER}"
export INSTALL_MODULES_ON_RESTART="${INSTALL_MODULES_ON_RESTART:-false}"
export MYSQL_VERSION="${MYSQL_VERSION:-5.7}"
export ON_INIT_SCRIPT_FAILURE="${ON_INIT_SCRIPT_FAILURE:-fail}"
export ON_INSTALL_MODULES_FAILURE="${ON_INSTALL_MODULES_FAILURE:-fail}"
export POST_SCRIPTS_DIR="${POST_SCRIPTS_DIR:-/tmp/post-scripts/}"
export POST_SCRIPTS_ON_RESTART="${POST_SCRIPTS_ON_RESTART:-false}"
export POST_SCRIPTS_USER="${POST_SCRIPTS_USER:-www-data}"
export POST_SCRIPTS_USER="${POST_SCRIPTS_USER:-$RUN_AS_USER}"
export PS_PROTOCOL="${PS_PROTOCOL:-http}"
export RUN_AS_USER="${RUN_AS_USER:-www-data}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RUN_AS_USER should be defined prior to its use (lines 10,17)

export SSL_REDIRECT="${SSL_REDIRECT:-false}"
export XDEBUG_ENABLED="${XDEBUG_ENABLED:-false}"

Expand All @@ -25,9 +26,9 @@ MODULES_INSTALLED_LOCK=/tmp/flashlight-modules-installed.lock
INIT_SCRIPTS_LOCK=/tmp/flashlight-init-scripts.lock
POST_SCRIPTS_LOCK=/tmp/flashlight-post-scripts.lock

# Runs everything as www-data
# Runs everything as $RUN_AS_USER
run_user () {
sudo -g www-data -u www-data -- "$@"
sudo -g "$RUN_AS_USER" -u "$RUN_AS_USER" -- "$@"
}

if [ ! -f $INIT_LOCK ] || [ "$INIT_ON_RESTART" = "true" ]; then
Expand All @@ -41,6 +42,12 @@ if [ ! -f $INIT_LOCK ] || [ "$INIT_ON_RESTART" = "true" ]; then
http*) echo "PS_DOMAIN is not expected to be an URI"; sleep 3; exit 2 ;;
esac

# Check if RUN_AS_USER is not www-data
if [ "$RUN_AS_USER" != "www-data" ]; then
sed -i "s/www-data/$RUN_AS_USER/g" /usr/local/etc/php-fpm.conf
sed -i "s/www-data/$RUN_AS_USER/g" /etc/nginx/nginx.conf
fi

# Check if a tunnel autodetection mechanism should be involved
if [ -n "${NGROK_TUNNEL_AUTO_DETECT+x}" ]; then
echo "* Auto-detecting domain with ngrok client api on ${NGROK_TUNNEL_AUTO_DETECT}..."
Expand Down Expand Up @@ -208,7 +215,7 @@ if [ "$DRY_RUN" = "true" ]; then
fi

echo "* Starting php-fpm..."
run_user php-fpm -D
run_user php-fpm -D -R

echo "* Starting nginx..."
nginx -g "daemon off;" &
Expand Down
4 changes: 2 additions & 2 deletions examples/xdebug-prestashop/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ services:
environment:
- PS_DOMAIN=localhost:8000
- INIT_SCRIPTS_DIR=/tmp/init-scripts
- INIT_SCRIPTS_USER=root
- RUN_AS_USER=root
- XDEBUG_ENABLED=true
volumes:
- ./PrestaShop:/var/www/html:rw
- ./PrestaShop:/var/www/html:delegated
ports:
- 8000:80

Expand Down
Loading