FROM php:8.1-fpm # Set working directory WORKDIR /var/www/html # Install system dependencies RUN apt-get update && apt-get install -y \ git \ curl \ libcurl4-openssl-dev \ pkg-config \ libpng-dev \ libonig-dev \ libxml2-dev \ libzip-dev \ zip \ unzip \ libfreetype6-dev \ libjpeg62-turbo-dev \ libxpm-dev \ libvpx-dev \ supervisor \ nginx \ nodejs \ npm \ vim \ nano \ htop \ && rm -rf /var/lib/apt/lists/* # Install PHP extensions RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-xpm \ && docker-php-ext-install -j$(nproc) \ curl \ pdo_mysql \ mbstring \ exif \ pcntl \ bcmath \ gd \ zip \ dom \ xml # Install Redis and Xdebug RUN pecl install redis xdebug \ && docker-php-ext-enable redis xdebug # Install Composer COPY --from=composer:latest /usr/bin/composer /usr/bin/composer # Copy dependency files first for better caching COPY composer.json composer.lock ./ COPY package.json package-lock.json ./ # Now copy the entire application code (after npm/composer install) COPY . . # Install PHP dependencies (with dev) RUN composer install --no-interaction # Install Node dependencies (cached if package-lock.json not changed) RUN npm install # Set ownership and permissions RUN mkdir -p storage/logs \ && mkdir -p storage/framework/{cache,sessions,views} \ && mkdir -p storage/app \ && mkdir -p bootstrap/cache \ && chown -R www-data:www-data /var/www/html \ && chmod -R 775 storage bootstrap/cache \ && chmod -R 755 public # Copy configs COPY ./docker/nginx.dev.conf /etc/nginx/sites-available/default COPY ./docker/supervisord.dev.conf /etc/supervisor/conf.d/supervisord.conf COPY ./docker/xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini # Expose web port + possible Webpack/Vite EXPOSE 80 3000 CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]