FROM alpine:3.19 # Install Apache, PHP 8.2, and the SQLite extensions RUN apk update && apk add --no-cache \ apache2 \ php82 \ php82-apache2 \ php82-pdo \ php82-pdo_sqlite \ php82-curl \ curl \ shadow # Symlink php82 to php so scripts run naturally if needed RUN ln -sf /usr/bin/php82 /usr/bin/php # Alpine keeps Apache site configs here instead of a2enmod RUN sed -i 's/#LoadModule rewrite_module/LoadModule rewrite_module/' /etc/apache2/httpd.conf && \ sed -i 's/#LoadModule headers_module/LoadModule headers_module/' /etc/apache2/httpd.conf && \ sed -i 's/DirectoryIndex index.html/DirectoryIndex index.php index.html/' /etc/apache2/httpd.conf && \ sed -i 's/^Listen 80$/Listen 8080/' /etc/apache2/httpd.conf && \ sed -i 's#^ErrorLog .*#ErrorLog /proc/self/fd/2#' /etc/apache2/httpd.conf && \ sed -i 's#^CustomLog .*#CustomLog /proc/self/fd/1 combined#' /etc/apache2/httpd.conf && \ if grep -q '^PidFile ' /etc/apache2/httpd.conf; then \ sed -i 's#^PidFile .*#PidFile /tmp/httpd.pid#' /etc/apache2/httpd.conf; \ else \ printf '\nPidFile /tmp/httpd.pid\n' >> /etc/apache2/httpd.conf; \ fi # Copy files directly into Alpine's default web root COPY . /var/www/localhost/htdocs/ RUN rm -f /var/www/localhost/htdocs/index.html # Set up the database directory permissions RUN mkdir -p /var/www/localhost/htdocs/db && \ chown -R apache:apache /var/www/localhost/htdocs/db && \ chmod -R 755 /var/www/localhost/htdocs/db # Match local user permissions for the runtime user (Alpine uses 'apache' instead of 'www-data') RUN usermod -u 1000 apache && \ groupmod -g 1000 apache && \ mkdir -p /run/apache2 /var/log/apache2 /tmp/website-lang && \ chown -R apache:apache /run/apache2 /var/log/apache2 /tmp/website-lang /var/www/localhost/htdocs/db ENV WEBSITE_LANG_WRITE_DIR=/tmp/website-lang USER apache EXPOSE 8080 # Start Apache in the foreground CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]