FROM dunglas/frankenphp:php8.2.29-bookworm

# Install required PHP extensions (ADD bcmath)
RUN install-php-extensions \
    bcmath \
    ctype curl dom fileinfo filter hash mbstring openssl pcre pdo session tokenizer xml

WORKDIR /app

COPY . .

# Install PHP deps (production safe)
RUN composer install --no-dev --optimize-autoloader --no-interaction

# Laravel permissions
RUN mkdir -p storage/framework/{sessions,views,cache,testing} storage/logs bootstrap/cache \
    && chmod -R 777 storage bootstrap/cache

EXPOSE 8080

CMD ["frankenphp", "run", "--config", "/Caddyfile"]
