Skip to content

Commit f3cb079

Browse files
committed
fix: Update Dockerfile and init script to include su-exec for user permissions and install Composer dependencies as www-data user.
1 parent 39839b1 commit f3cb079

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

docker/frankenphp/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ ENV COMPOSER_ALLOW_SUPERUSER=1
3434
# Change PHP config
3535
COPY docker/php/php.ini /usr/local/etc/php/conf.d/base.ini
3636

37-
# Install supervisord and Node.js (includes npm)
37+
# Install supervisord, Node.js, and su-exec
3838
RUN apt-get update && apt-get install -y \
3939
supervisor \
4040
curl \
41+
su-exec \
4142
--no-install-recommends \
4243
&& curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \
4344
&& apt-get install -y nodejs \

docker/init.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,13 @@ echo -e "${GREEN}Setup completed.${NC}"
4848
if [ -f "/app/composer.json" ] && [ ! -d "/app/vendor" ]; then
4949
echo -e "${YELLOW}Installing Composer dependencies...${NC}"
5050

51-
# Install dependencies based on environment
51+
# Install dependencies based on environment AS www-data user
5252
if [ "$YII_ENV" = "prod" ]; then
5353
# Production: exclude dev dependencies and optimize autoloader
54-
composer install --no-dev --optimize-autoloader --no-interaction
54+
su-exec www-data composer install --no-dev --optimize-autoloader --no-interaction
5555
else
5656
# Development: include dev dependencies
57-
composer install --optimize-autoloader --no-interaction
58-
fi
59-
60-
# Set proper ownership for vendor directory if possible
61-
if chown -R www-data:www-data /app/vendor 2>/dev/null; then
62-
echo -e "${GREEN}✓ Vendor directory ownership set${NC}"
57+
su-exec www-data composer install --optimize-autoloader --no-interaction
6358
fi
6459

6560
echo -e "${GREEN}✓ Composer dependencies installed successfully.${NC}"

0 commit comments

Comments
 (0)