# Using the slim version of 8.4; it's much more stable with Podman
FROM docker.io/php:8.4-fpm-alpine

WORKDIR /var/www

# Use the installer to get your specific extensions without the manual tar extraction
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN chmod +x /usr/local/bin/install-php-extensions && \
    install-php-extensions pdo_mysql mbstring exif pcntl bcmath gd zip intl

# Get latest Composer
COPY --from=docker.io/composer:latest /usr/bin/composer /usr/bin/composer

# Copy application files
COPY . /var/www

# Fix permissions for the www-data user
RUN chown -R www-data:www-data /var/www && \
    chmod -R 755 /var/www/storage /var/www/bootstrap/cache

USER www-data

EXPOSE 8000

CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]