FROM dunglas/frankenphp:php8.4-alpine


WORKDIR /app


RUN install-php-extensions \
    pdo_pgsql \
    opcache \
    pcntl \
    zip \
    intl


COPY --from=composer:2 /usr/bin/composer /usr/bin/composer


COPY composer.json composer.lock ./


RUN composer install \
    --no-dev \
    --no-interaction \
    --prefer-dist \
    --optimize-autoloader


COPY . .


RUN npm install
RUN npm run build


RUN php artisan octane:install --server=frankenphp || true


RUN php artisan config:cache
RUN php artisan route:cache
RUN php artisan view:cache


RUN chown -R www-data:www-data storage bootstrap/cache


EXPOSE 8000


CMD ["frankenphp", "php-server", "--listen", "0.0.0.0:8000"]
