# Use the official PHP image with PHP 8.1 FROM php:8.1-apache # Install necessary packages and PHP extensions RUN apt-get update && apt-get install -y \ wget \ git \ gnupg \ lsb-release \ apt-transport-https \ ca-certificates \ libpq-dev \ libsqlite3-dev \ zip \ unzip \ && docker-php-ext-install pgsql pdo_pgsql pdo_sqlite mysqli pdo_mysql # Install Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer # Copy the Laravel project into the container COPY ./php/ /var/www/html # Ensure .env file is copied COPY ./php/.env /var/www/html/.env # Run composer update to ensure compatible versions of dependencies RUN composer update --working-dir=/var/www/html --no-scripts # Set Apache DocumentRoot to Laravel's public directory RUN sed -i 's|/var/www/html|/var/www/html/public|' /etc/apache2/sites-available/000-default.conf # Change Apache to listen on port 7860 RUN sed -i 's/Listen 80/Listen 7860/' /etc/apache2/ports.conf \ && sed -i 's/:80/:7860/' /etc/apache2/sites-available/000-default.conf # Set correct permissions for Laravel directories RUN chown -R www-data:www-data /var/www/html \ && find /var/www/html -type d -exec chmod 755 {} \; \ && find /var/www/html -type f -exec chmod 644 {} \; # Ensure the storage and cache directories have the correct permissions RUN mkdir -p /var/www/html/storage \ && mkdir -p /var/www/html/bootstrap/cache \ && chown -R www-data:www-data /var/www/html/storage \ && chown -R www-data:www-data /var/www/html/bootstrap/cache \ && chmod -R 775 /var/www/html/storage \ && chmod -R 775 /var/www/html/bootstrap/cache # Expose the Apache port EXPOSE 7860 # Start Apache CMD ["apache2-foreground"]