FROM wordpress:6.9.4-php8.2-apache # Use the PORT environment variable provided by Hugging Face (default 7860) ENV PORT 7860 RUN sed -i "s/80/${PORT}/g" /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf # Explicitly enable mod_rewrite RUN a2enmod rewrite # Force AllowOverride All for .htaccess support RUN { \ echo ''; \ echo ' AllowOverride All'; \ echo ''; \ } > /etc/apache2/conf-available/allow-override.conf && a2enconf allow-override # Copy everything from the repo to the template directory COPY . /usr/src/wordpress/ # Ensure correct permissions in the template RUN chown -R www-data:www-data /usr/src/wordpress/ # Custom command to force-sync our files to the active /var/www/html before starting Apache # This handles the case where /var/www/html already exists and the standard entrypoint skips copying. CMD ["sh", "-c", "cp -r /usr/src/wordpress/. /var/www/html/ && chown -R www-data:www-data /var/www/html/ && exec apache2-foreground"]