Codeigniter 3 dockerization error while using mysqli_connect()

64 Views Asked by At

I'm new to docker and I have codeigniter project. I tried to dockerize my project. In my project I am connecting another database using mysqli_connnect. But there am getting error. I am not dockerizing the mysql

Please help me to resolve it.

Dockerfile

FROM php:8.1.6-apache 
RUN apt-get update && \ apt-get install -y 
RUN apt-get install -y curl 
RUN apt-get install -y build-essential libssl-dev zlib1g-dev libpng-dev libjpeg-dev libfreetype6-dev 
RUN apt-get install -y libicu-dev 
COPY ./app/ /var/www/html/ 
RUN apt-get update 
RUN docker-php-ext-install intl 
RUN docker-php-ext-configure intl 
RUN docker-php-ext-install mysqli pdo pdo_mysql 
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli 
RUN a2enmod rewrite 
RUN service apache2 restart

docker-compose.yml

version: '3' 
services: 
    web: container_name: stafzy_dev 
    image: stafzy 
    ports: - 80:80 
    volumes: - ./app/:/var/www/html/`

here is the code to connect db -> file: db_setup.php line no: 38

$connection = @mysqli_connect($db['default']['hostname'], $db['default']['username'], $db['default']['password'], $db['default']['database']);`

this is the error am getting in log:

ERROR - 2023-10-22 10:59:05 Controller: login & Method: index & Client: demo1 --> Severity: error --> Exception: No such file or directory /var/www/html/application/config/db_setup.php 38
0

There are 0 best solutions below