I have created a simple tech stack using Docker. PHP 7.2 on CentOS.
Below is the docker file
FROM centos:7
# Install Apache
RUN yum -y update
RUN yum -y install httpd httpd-tools
# Install EPEL Repo
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
&& rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
# Install PHP
RUN yum -y install php72w php72w-bcmath php72w-cli php72w-common php72w-gd php72w-intl php72w-ldap php72w-mbstring \
php72w-mysql php72w-pear php72w-soap php72w-xml php72w-xmlrpc
# Update Apache Configuration
RUN sed -E -i -e '/<Directory "\/var\/www\/html">/,/<\/Directory>/s/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
RUN sed -E -i -e 's/DirectoryIndex (.*)$/DirectoryIndex index.php \1/g' /etc/httpd/conf/httpd.conf
EXPOSE 80
# Start Apache
CMD ["/usr/sbin/httpd","-D","FOREGROUND"]
Below is the docker-compose.yml
version: '3.2'
services:
centos-php-apache:
build:
context: ./
ports:
- "8080:80"
volumes:
- ./code:/var/www/html
All is now running fine. After few days, I decided to update the following -
(i) Update “dockerfile” by adding another php-module or php-extension
(ii) Update the docker compose.yml by adding another service (say) “mariadb”.
I would like to do this update, without effecting or deleting any files from the previous setup. In fact, this is a common scenario, where developers may need additional extensions or service in the future - without redoing everything right from the beginning.
Should I directly edit the "dockerfile" and add the php extension and edit the docker-compose.yml file and add the service as usual and then run the docker-compose up command. Of course before running the "up" command, I will first bring it down using the docker-compose down command.
Can anyone throw some light, on how I can accomplish this.