Run deploy commands as www-data for correct file ownership

SSH key copied to /var/www/.ssh/ for www-data GitHub access.
All git, composer, and console commands now run as www-data so
var/cache/ files are always owned correctly without a manual chown.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Simon Kühn 2026-04-29 20:39:27 +02:00
parent d7edb30998
commit 6503466344

View file

@ -4,14 +4,16 @@ set -e
cd "$(dirname "$0")"
git pull
COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev --no-interaction --optimize-autoloader --ignore-platform-reqs
RUN="su -s /bin/sh www-data -c"
$RUN "git pull"
$RUN "COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev --no-interaction --optimize-autoloader --ignore-platform-reqs"
# Alias-Deployment: RewriteBase auf /dd/ setzen
sed -i 's|RewriteBase /$|RewriteBase /dd/|' public/.htaccess
APP_ENV=prod php bin/console doctrine:migrations:migrate --no-interaction --env=prod
APP_ENV=prod php bin/console cache:clear --env=prod --no-warmup
chown -R www-data:www-data var/
$RUN "APP_ENV=prod php bin/console doctrine:migrations:migrate --no-interaction --env=prod"
$RUN "APP_ENV=prod php bin/console cache:clear --env=prod --no-warmup"
$RUN "APP_ENV=prod php bin/console cache:warmup --env=prod"
echo "Deploy fertig."