FROM php:8.3-fpm # Install system dependencies RUN apt-get update && apt-get install -y \ libzip-dev \ libpng-dev \ postgresql-client \ libpq-dev \ unzip \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* # Install composer COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer ENV COMPOSER_ALLOW_SUPERUSER=1 # Install PHP extensions RUN docker-php-ext-install pdo pgsql pdo_pgsql gd bcmath zip \ && pecl install redis \ && docker-php-ext-enable redis WORKDIR /usr/share/nginx/html/ # Create storage directories RUN mkdir -p storage/framework/sessions \ storage/framework/views \ storage/framework/cache \ storage/logs \ storage/app/public \ bootstrap/cache \ && chown -R www-data:www-data storage bootstrap/cache \ && chmod -R 775 storage bootstrap/cache # Copy composer files and helpers.php first COPY api/composer.json api/composer.lock ./ COPY api/app/helpers.php ./app/helpers.php # Install dependencies without running scripts RUN if [ "$APP_ENV" = "production" ] ; then \ composer install --no-dev --no-scripts --ignore-platform-req=php --optimize-autoloader ; \ else \ composer install --no-scripts --ignore-platform-req=php --optimize-autoloader ; \ fi # Copy the rest of the application COPY api/ . # Run composer scripts and clear cache RUN composer dump-autoload -o \ && php artisan package:discover --ansi \ && composer clear-cache \ && chmod -R 775 storage \ && chown -R www-data:www-data storage # Setup entrypoint COPY docker/php-fpm-entrypoint /usr/local/bin/opnform-entrypoint RUN chmod a+x /usr/local/bin/* ENTRYPOINT ["/usr/local/bin/opnform-entrypoint"] CMD ["php-fpm"]