|
| 1 | +# syntax=docker/dockerfile:1 |
| 2 | + |
| 3 | +# Build a production image for phpList base-distribution (Symfony-based) |
| 4 | +FROM php:8.1-apache-bullseye |
| 5 | + |
| 6 | +# Set workdir |
| 7 | +WORKDIR /var/www/html |
| 8 | + |
| 9 | +# Install system dependencies and PHP extensions |
| 10 | +RUN apt-get update \ |
| 11 | + && apt-get install -y --no-install-recommends \ |
| 12 | + git unzip libzip-dev libicu-dev libpng-dev libonig-dev libxml2-dev \ |
| 13 | + libc-client2007e-dev libkrb5-dev libssl-dev \ |
| 14 | + && docker-php-ext-configure intl \ |
| 15 | + && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ |
| 16 | + && docker-php-ext-install -j"$(nproc)" \ |
| 17 | + pdo pdo_mysql zip intl imap \ |
| 18 | + && rm -rf /var/lib/apt/lists/* |
| 19 | + |
| 20 | +# Enable Apache modules and set DocumentRoot to /public |
| 21 | +RUN a2enmod rewrite headers \ |
| 22 | + && sed -ri 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/000-default.conf \ |
| 23 | + && sed -ri 's!/var/www/!/var/www/html/public!g' /etc/apache2/apache2.conf \ |
| 24 | + && echo "<Directory /var/www/html/public>\n AllowOverride All\n Require all granted\n</Directory>" > /etc/apache2/conf-available/phplist.conf \ |
| 25 | + && a2enconf phplist |
| 26 | + |
| 27 | +# Copy composer definition first and install dependencies |
| 28 | +COPY composer.json composer.lock ./ |
| 29 | + |
| 30 | +# Install Composer |
| 31 | +ENV COMPOSER_ALLOW_SUPERUSER=1 \ |
| 32 | + PATH="/usr/local/bin:${PATH}" |
| 33 | +RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ |
| 34 | + && php composer-setup.php --install-dir=/usr/local/bin --filename=composer \ |
| 35 | + && rm composer-setup.php |
| 36 | + |
| 37 | +# Ensure config directory exists for Composer scripts that write into it |
| 38 | +COPY config ./config |
| 39 | + |
| 40 | +# Install PHP dependencies (include scripts so phpList creates config structure) |
| 41 | +RUN composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader |
| 42 | + |
| 43 | +# Copy the rest of the application (except files ignored by .dockerignore) |
| 44 | +COPY . . |
| 45 | + |
| 46 | +# Ensure correct permissions for cache/logs |
| 47 | +RUN chown -R www-data:www-data var public \ |
| 48 | + && find var -type d -exec chmod 775 {} \; \ |
| 49 | + && find var -type f -exec chmod 664 {} \; |
| 50 | + |
| 51 | +# Expose port and run Apache |
| 52 | +EXPOSE 80 |
| 53 | +CMD ["apache2-foreground"] |
0 commit comments