Some minor fixes to handle write permissions
This commit is contained in:
@@ -19,5 +19,10 @@ RUN mkdir -p /usr/local/etc/php/conf.d && \
|
|||||||
# Set default timezone to avoid TZ error in s6-overlay
|
# Set default timezone to avoid TZ error in s6-overlay
|
||||||
ENV TZ=UTC
|
ENV TZ=UTC
|
||||||
|
|
||||||
|
# Create custom startup script in s6 init directory (runs during container init)
|
||||||
|
RUN mkdir -p /etc/cont-init.d && \
|
||||||
|
printf '#!/bin/bash\n# Fix writable directories for Piwigo\nset -e\n\n# Ensure _data directory exists\nmkdir -p /var/www/html/_data\n\n# Fix permissions on all writable directories\nfor dir in /var/www/html/_data /var/www/html/upload /var/www/html/galleries; do\n if [ -d "$dir" ]; then\n chown -R www-data:www-data "$dir" 2>/dev/null || true\n chmod -R 775 "$dir" 2>/dev/null || true\n fi\n mkdir -p "$dir"\n chown -R www-data:www-data "$dir" 2>/dev/null || true\n chmod -R 775 "$dir" 2>/dev/null || true\n find "$dir" -type d -name "templates_c" -exec chmod -R 777 {} \\; 2>/dev/null || true\n find "$dir" -type d -name "themes" -exec chmod -R 777 {} \\; 2>/dev/null || true\ndone\n\n# Also fix templates_c anywhere in _data\nfind /var/www/html/_data -type d -name "templates_c" -exec chmod -R 777 {} \\; 2>/dev/null || true\nfind /var/www/html/_data -type d -name "themes" -exec chmod -R 777 {} \\; 2>/dev/null || true\n\n# If config exists but no database, wait for DB\nif [ -f "/var/www/html/local/config/config.inc.php" ]; then\n echo "Config found, checking database connection..."\n \n DB_HOST=$(grep -oP '"'"'"'"'"'"'db_host'"'"'"'"'"'"'\s*=>\s*'"'"'"'"'"'"'\K[^'"'"'"'"'"'"']+'"'"'"'"'"'"' /var/www/html/local/config/config.inc.php 2>/dev/null || echo "db")\n DB_USER=$(grep -oP '"'"'"'"'"'"'db_user'"'"'"'"'"'"'\s*=>\s*'"'"'"'"'"'"'\K[^'"'"'"'"'"'"']+'"'"'"'"'"'"' /var/www/html/local/config/config.inc.php 2>/dev/null || echo "piwigo")\n DB_PASS=$(grep -oP '"'"'"'"'"'"'db_password'"'"'"'"'"'"'\s*=>\s*'"'"'"'"'"'"'\K[^'"'"'"'"'"'"']+'"'"'"'"'"'"' /var/www/html/local/config/config.inc.php 2>/dev/null || echo "")\n DB_NAME=$(grep -oP '"'"'"'"'"'"'db_name'"'"'"'"'"'"'\s*=>\s*'"'"'"'"'"'"'\K[^'"'"'"'"'"'"']+'"'"'"'"'"'"' /var/www/html/local/config/config.inc.php 2>/dev/null || echo "piwigo")\n \n for i in {1..30}; do\n if mariadb -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASS" -e "SELECT 1" "$DB_NAME" >/dev/null 2>&1; then\n echo "Database connection successful"\n break\n fi\n echo "Waiting for database... ($i/30)"\n sleep 2\n done\nfi\n' > /etc/cont-init.d/99-custom-startup && \
|
||||||
|
chmod +x /etc/cont-init.d/99-custom-startup
|
||||||
|
|
||||||
# Use base image's entrypoint (docker-php-entrypoint)
|
# Use base image's entrypoint (docker-php-entrypoint)
|
||||||
# The base image already handles permissions and Apache startup
|
# The base image already handles permissions and Apache startup
|
||||||
Reference in New Issue
Block a user