README.md
Rendering markdown...
# Use the official PHP 7.2 Apache base image
FROM php:7.2-apache
# Install PHP extensions and other dependencies
RUN apt-get update && \
apt-get install -y \
libpng-dev \
libjpeg-dev \
libpq-dev \
default-mysql-client \
&& \
docker-php-ext-install -j$(nproc) \
gd \
mysqli \
pdo_mysql \
opcache \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install MySQL and configure the "test" database
RUN apt-get update && \
apt-get install -y \
default-mysql-server \
&& \
rm -rf /var/lib/apt/lists/* && \
service mysql start && \
mysql -e "CREATE DATABASE test;" && \
service mysql stop
# Enable Apache modules
RUN a2enmod rewrite
# Set the document root
ENV APACHE_DOCUMENT_ROOT /var/www/html
# Update the default Apache site with the document root
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
# Copy your web application files into the container
COPY file ${APACHE_DOCUMENT_ROOT}
# Set permissions for Apache to access the files
RUN chown -R www-data:www-data ${APACHE_DOCUMENT_ROOT}
# Expose port 80 for Apache
EXPOSE 80
# Start the MySQL and Apache servers
CMD service mysql start && apache2-foreground