@@ -8,6 +8,12 @@ NC='\033[0m'
88
99echo -e " ${GREEN} Starting container setup...${NC} "
1010
11+ # Create necessary Caddy directories with proper permissions
12+ echo -e " ${YELLOW} Creating Caddy directories...${NC} "
13+ mkdir -p /data/caddy/locks /config/caddy
14+ chown -R www-data:www-data /data /config
15+ chmod -R 755 /data /config
16+
1117# Create necessary Yii2 directories if they don't exist
1218echo -e " ${YELLOW} Creating Yii2 directories...${NC} "
1319mkdir -p /app/runtime/cache
@@ -48,29 +54,27 @@ echo -e "${GREEN}Setup completed.${NC}"
4854if [ -f " /app/composer.json" ] && [ ! -d " /app/vendor" ]; then
4955 echo -e " ${YELLOW} Installing Composer dependencies...${NC} "
5056
51- # Install dependencies based on environment
57+ # Make /app writable by www-data for mounted volumes
58+ chmod 777 /app
59+
60+ # Install dependencies with proper environment variables
5261 if [ " $YII_ENV " = " prod" ]; then
5362 # Production: exclude dev dependencies and optimize autoloader
54- composer install --no-dev --optimize-autoloader --no-interaction
63+ gosu www-data env \
64+ HOME=/var/www \
65+ COMPOSER_HOME=/var/www/.composer \
66+ COMPOSER_CACHE_DIR=/var/www/.composer/cache \
67+ composer install --no-dev --optimize-autoloader --no-interaction
5568 else
5669 # 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} "
70+ gosu www-data env \
71+ HOME=/var/www \
72+ COMPOSER_HOME=/var/www/.composer \
73+ COMPOSER_CACHE_DIR=/var/www/.composer/cache \
74+ composer install --optimize-autoloader --no-interaction
6375 fi
6476
65- echo -e " ${GREEN} ✓ Composer dependencies installed successfully.${NC} "
66- fi
67-
68- # Set permissions for node_modules directory if it exists
69- if chown -R www-data:www-data /app/node_modules 2> /dev/null; then
70- chmod -R 775 /app/node_modules
71- echo -e " ${GREEN} ✓ Node modules directory ownership set${NC} "
72- else
73- echo -e " ${YELLOW} ⚠ Node modules directory ownership could not be set (mounted volume?)${NC} "
77+ echo -e " ${GREEN} ✓ Composer dependencies installed successfully${NC} "
7478fi
7579
7680echo -e " ${GREEN} Starting supervisord...${NC} "
0 commit comments