Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 4 and Docker
#11

I guess you don't have a MySQL database configured ...
Create an empty folder on the server
Inside the folder you created, add a new file and call it docker-compose.yml


Code:
version: "3"

services:
#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
#                    C O D E I G N I T E R  v4.0.2                      #
#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
    codeigniter4:
        image: atsanna/codeigniter4:latest
        container_name: 'codeigniter4'
        ports:
          - 80:80
        links:
          - codeigniter4_mysql
        volumes:
          - ./localfolder/www:/var/www/html

#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
#                              M Y S Q L                                  #
#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#               
    codeigniter4_mysql:
        image: mysql:8.0.19
        container_name: 'codeigniter4_mysql'
        ports:
          - 3306:3306
        volumes:
          - ./localfolder/mysql:/var/lib/mysql
          - ./localfolder/logs/mysql:/var/log/mysql
        environment:
          MYSQL_ROOT_PASSWORD: rootpassword
          MYSQL_DATABASE: dbname
          MYSQL_USER: codeigniter4
          MYSQL_PASSWORD: codeigniter4

#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#
#                        P H P M Y A D M I N                              #
#--------------------------------------------------------------------------#
#--------------------------------------------------------------------------#             
    codeigniter4_phpmyadmin:
        image: phpmyadmin/phpmyadmin:5.0.2
        container_name: 'codeigniter4_phpmyadmin'
        links:
          - codeigniter4_mysql
        environment:
          PMA_HOST: codeigniter4_mysql
          PMA_PORT: 3306
        ports:
          - 81:80
        volumes:
          - ./localfolder/sessions:/sessions

Change the following values

Code:
MYSQL_ROOT_PASSWORD: rootpassword
           MYSQL_DATABASE: dbname
           MYSQL_USER: codeigniter4
           MYSQL_PASSWORD: codeigniter4

Now connect with the console in the path where you stored the file docker-compose.yml and type

Code:
docker-compose up -d

The necessary folders will be created and the services will start.

Now you need to configure codeigiter to connect to the mysql server at the localhost address on port 3306

at http://yourserver you will find codeigniter
at http://yourserver:81 replies phpmyadmin


To stop the services, always inside the folder where the docker-compose.yml file is located, you can type

Code:
docker-compose down --volumes
Codeigniter 4 - Docker Image [github] [docker hub]
Reply
#12

(09-26-2019, 07:38 AM)ciadmin Wrote: Manual install is still an option (https://codeigniter4.github.io/userguide...anual.html).
Composer install of the appstarter works out of the box, as far as we know. Which composer install are you referring to?
RUnning the local (spark) server is an *option* for those who don't want to configure their server.

"Docker" is coming, this quarter Smile

Looking forward to it, I've been waiting for this kind of thread.
"The capacity to learn is a gift, the ability to learn is a skill, but the willingness to learn is a choice."
Reply
#13

The image of the CodeIgniter docker hub has been updated to v4.0.3
Codeigniter 4 - Docker Image [github] [docker hub]
Reply
#14

Hello,

I've created some tutorials on how to set up Docker containers for CodeIgniter. Please, give them a try, and tell me your opinion:

https://avenir.ro/codeigniter-4/codeigni...che-mysql/
https://avenir.ro/codeigniter-4/install-...ontainers/
Reply
#15

(04-13-2020, 10:31 AM)atsanna Wrote: I have improved the docker file and want to share the changes with you.

You can find the update on github at this address

https://github.com/atsanna/codeigniter4-docker

With this new version you should be able to mount the folder on the host.
Thank you!
codeigniter4-docker worked for me.
Reply
#16

version: "3"

services:

# C O D E I G N I T E R  v4.1.8

    codeigniter4:
        # image: atsanna/codeigniter4:latest
        # image: atsanna/codeigniter4:v4.1.8-php7.4
        image: atsanna/codeigniter4:v4.1.8-php8.0
        container_name: 'codeigniter4'
        ports:
          - 8000:80
        links:
          - codeigniter4_mysql
        volumes:
          - .:/var/www/html/codeigniter4

#  M Y S Q L
     
    codeigniter4_mysql:
        image: mariadb:10.5.5
        container_name: 'codeigniter4_mysql'
        ports:
          - 3306:3306
        # volumes:
        #  - ./localfolder/mysql:/var/lib/mysql
        #  - ./localfolder/logs/mysql:/var/log/mysql
        environment:
          MYSQL_ROOT_PASSWORD: rootpassword
          MYSQL_DATABASE: codeigniter4
          MYSQL_USER: codeigniter4
          MYSQL_PASSWORD: codeigniter4

# unComment if you need
# P H P M Y A D M I N
       
    # codeigniter4_phpmyadmin:
    #    image: phpmyadmin/phpmyadmin:5.0.2
    #    container_name: 'codeigniter4_phpmyadmin'
    #    links:
    #      - codeigniter4_mysql
    #    environment:
    #      PMA_HOST: codeigniter4_mysql
    #      PMA_PORT: 3306
    #    ports:
    #      - 81:80
    #    volumes:
    #      - ./localfolder/sessions:/sessions
Reply




Theme © iAndrew 2016 - Forum software by © MyBB