How to containerise CodeIgniter project using Docker? How to containerise CodeIgniter project using Docker? codeigniter codeigniter

How to containerise CodeIgniter project using Docker?


I use docker with Codeigniter 4 on daily basis. Here's my structure, although in my structure I'm not using neither redis or nginx. I'm using apache instead.

Folder structure:

.database.docker  |php     |sites-available       |site.conf     |Dockerfile  |custom.ini  |docker-compose.yml.gitapp  |app  |public  |tests  |vendor  |writable  |.env  |composer.json  |composer.lock  |spark.gitignore

As for the config files, here's the docker-compose.yml

version: '3'services:    web:        container_name: ci4-web        build:            context: ./php        ports:            - 80:80        volumes:            - ../app:/var/www/html/app/            - ./custom.ini:/usr/local/etc/php/conf.d/custom.ini        links:            - mysql        depends_on:          - mysql    mysql:        container_name: db-ci4        image: mysql:latest        volumes:            - ./db:/var/lib/mysql        command: --default-authentication-plugin=mysql_native_password        ports:            - 3306:3306        environment:            MYSQL_ROOT_PASSWORD: root

The Dockerfile

FROM php:7.2-apacheRUN apt-get update && \    apt-get install -yRUN apt-get install -y curlRUN apt-get install -y build-essential libssl-dev zlib1g-dev libpng-dev libjpeg-dev libfreetype6-devRUN apt-get install -y libicu-devCOPY sites-available/elioter.conf /etc/apache2/sites-enabled/elioter.confRUN apt-get updateRUN docker-php-ext-install intlRUN docker-php-ext-configure intlRUN docker-php-ext-install mysqli pdo pdo_mysql zip mbstringRUN a2enmod rewriteRUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \    && docker-php-ext-install gdRUN service apache2 restart

my site.conf

<VirtualHost *:80>    DocumentRoot "/var/www/html/app/public/"    ServerName ci4.local    <Directory "/var/www/html/app/public/">        AllowOverride all    </Directory></VirtualHost>

On my youtube series about codeigniter 4 I created a github repo that reflects this structure:


I came across this question when I was learning docker and wanted to leave an update here. I'm using bitnami/codeigniter3. This was easy for me as I did not have to migrate my application to Codeigniter 4.