# Use PHP 8.3 image with Apache
FROM public.ecr.aws/docker/library/php:8.1-apache

# Enable Apache mod_rewrite
RUN a2enmod rewrite headers 

# Set the working directory
WORKDIR /var/www/theme.cpx.ae/

# Copy the application code into the container
COPY . /var/www/theme.cpx.ae/

COPY theme.cpx.ae.conf /etc/apache2/sites-available/

COPY entrypoint.sh /usr/local/bin/entrypoint.sh

RUN chmod +x /usr/local/bin/entrypoint.sh

# Expose the container's port 80
EXPOSE 80

# Ensure correct permissions
RUN find . -type f -exec chmod 644 {} \;
RUN find . -type d -exec chmod 755 {} \;

# Change ownership
RUN chown -R www-data:www-data /var/www/theme.cpx.ae/

# Start Apache in the foreground
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
