FROM docker.arvancloud.ir/php:8.3-fpm-alpine3.21

# Install common PHP extension dependencies
RUN apk update && apk add --no-cache \
    bash \
    nano \
    curl \
    libpng \
    libpng-dev \
    libjpeg-turbo-dev \
    freetype-dev \
    libwebp-dev \
    libxml2-dev \
    unzip \
    libzip-dev \
    libpq-dev \
    && docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
    && docker-php-ext-install pdo_pgsql gd zip

# Set the working directory
WORKDIR /var/www/laravel
COPY . .

RUN chmod -R 777 /var/www/laravel/storage /var/www/laravel/bootstrap/cache

# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Default command
CMD composer install \
    && php artisan key:generate \
    && php artisan migrate \
    && php artisan db:seed \
    && php-fpm
