# Use PHP 7.2 with Apache (mcrypt available via PECL, compatible with Laravel 5.0) FROM php:7.2-apache # Redirect to archived Debian Buster repositories (EOL) RUN sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list \ && sed -i 's|security.debian.org|archive.debian.org|g' /etc/apt/sources.list \ && sed -i '/buster-updates/d' /etc/apt/sources.list # Install system dependencies RUN apt-get update && apt-get install -y --allow-unauthenticated \ git \ curl \ libpng-dev \ libxml2-dev \ libmcrypt-dev \ zip \ unzip \ libfreetype6-dev \ libjpeg62-turbo-dev \ openssh-client \ libzip-dev \ && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ && docker-php-ext-install -j$(nproc) gd # Install mcrypt via PECL (removed from core in PHP 7.2) RUN pecl install mcrypt-1.0.4 && docker-php-ext-enable mcrypt # Suppress E_DEPRECATED so PECL mcrypt functions don't trigger ErrorException in Laravel 5.0 RUN echo "error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT" > /usr/local/etc/php/conf.d/suppress-deprecated.ini # Install PHP extensions RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath tokenizer zip # Enable Apache mod_rewrite RUN a2enmod rewrite # Install Composer 2.2 (LTS version supporting PHP 7.2+) COPY --from=composer:2.2 /usr/bin/composer /usr/bin/composer # Set working directory WORKDIR /var/www/html # Copy existing application directory contents COPY . /var/www/html # Create storage directories and set permissions RUN mkdir -p storage/framework/views \ storage/framework/cache \ storage/framework/sessions \ storage/logs \ bootstrap/cache # Set proper ownership and permissions RUN chown -R www-data:www-data /var/www/html \ && chmod -R 775 /var/www/html/storage \ && chmod -R 775 /var/www/html/bootstrap/cache # Create .env file if it doesn't exist RUN if [ ! -f .env ]; then cp .env.example .env; fi # Install PHP dependencies (--no-plugins skips kylekatarnls/update-helper which is Composer 1 only) RUN composer install --no-dev --no-interaction --prefer-dist --no-plugins # Generate application key RUN php artisan key:generate || true # Run Laravel 5.0 optimization RUN php artisan clear-compiled && php artisan optimize # Note: PHP 7.2 is compatible with Laravel 5.0 and yakpro-po obfuscation # Configure Apache DocumentRoot to point to Laravel's public directory ENV APACHE_DOCUMENT_ROOT=/var/www/html/public RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf # Suppress Apache ServerName warning RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf # Copy entrypoint script COPY docker-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/docker-entrypoint.sh # Expose port 80 EXPOSE 80 # Use entrypoint to set up permissions before starting Apache ENTRYPOINT ["docker-entrypoint.sh"] CMD ["apache2-foreground"]