# Use an official PHP runtime as a parent image
FROM php:7.4-fpm
# Set the working directory to /var/www/html
WORKDIR /var/www/html
# Install any needed extensions
RUN docker-php-ext-install pdo pdo_mysql
# Install Composer globally
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Install Supervisor for process control
RUN apt-get update && apt-get install -y supervisor && \
    mkdir -p /var/log/supervisor
# Copy the application code into the container
COPY . /var/www/html
# Run Composer install
RUN composer install
# Copy the Laravel worker configuration
COPY ./worker.conf /etc/supervisor/conf.d/
# Start Supervisor to manage the Laravel worker process
CMD ["/usr/bin/supervisord", "-n"]