Dockerize the Codeigniter application with rest apis also implement the JWT authentication.
Initial configuration for a project using Code Igniter 4.5, MySQL, Nginx and Docker
First make the clone of this repository
$ git clone https://github.com/Asad-Iftikhar/codeigniter4.5-restapi-docker-compose.git
With the repository ready, open the file .env
located at the root and configure it according to your database host.
Go to codeigniter4.5-restapi-docker-compose/web/app/app/Config
and open the file Database.php
. Change the database fields for them used in the .env
file.
OR
Update the .env file inside web directory according to the root .env like database credentials
After configuring the files, go to the root of the project and execute
To make your own local domain/host rename the codeigniter.conf name into folder below path
$ cd codeigniter4.5-restapi-docker-compose/docker/nginx/
give it your own local domain name as currently it will open at https://codeigniter You also need to add this entry into your host file
$ sudo nano /etc/hosts
127.0.0.1 YOUR_LOCAL_SITE_NAME
done, the application is ready for use.
To access your project, type in your browser
http://YOUR_LOCAL_SITE_NAME
To access the phpmyadmin, type in your browser
http://localhost:9191
To access a container shell, type in your terminal
$ sudo docker exec -ti <container_id> /bin/sh/
$ docker exec -it app-codeigniter4 sh
For details on how to use Code Igniter 4, visit the documentation.