FROM dunglas/frankenphp:php8.3-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 [
    "php",
    "artisan",
    "octane:start",
    "--server=frankenphp",
    "--host=0.0.0.0",
    "--port=8000"
]
