Skip to content
This repository has been archived by the owner. It is now read-only.

Latest commit

 

History

History
executable file
·
192 lines (149 loc) · 8.88 KB

File metadata and controls

executable file
·
192 lines (149 loc) · 8.88 KB

CakePHP 3.6 Docker Container

A CakePHP Docker Container which installs a fresh, fully configured and operational version of CakePHP 3.6. It comes with two pre-configured databases, for both production and testing environments and the app runs on PHP 7.0 up to 7.3, Apache 2.4 (or Nginx 1.14) and MariaDB 10.1 (read the MariaDB versus MySQL note below on why MariaDB was chosen over MySQL).

CakePHP 3.6.11

Installation

Installation is dead-easy. Just run the following command and then visit your browser (e.g. http://192.168.99.1) to see your newly configured CakePHP website.

docker run -p 80:80 justinhartman/cakephp3.5-php7-mysql-apache2:latest

Supported Tags and respective Dockerfile links

Below are tags to various PHP versions running either Apache or Nginx which come pre-installed in all the containers. Pick the version of PHP and web-server of your choosing, based on the tags below, when installing or running a container.

Apache PHP 7

You have two options when installing PHP with Apache 2.4. These are the built in Apache 2 PHP module (mod_php) or the stand-alone FastCGI PHP server (php-fpm). You can install either mod_php or php-fpm by selecting one of the tags below.

mod_php

php-fpm

The mod_php and php-fpm Docker containers also come with the following additional software installed:

  1. CakePHP 3.6.11
  2. Apache 2.4.34
  3. MariaDB 10.1.35

Nginx PHP-FPM 7

By default the Nginx Docker containers all run on the stand-alone FastCGI PHP server (php-fpm) and are pre-configured with this deployment of PHP.

The nginx containers also come with the following additional software installed:

  1. CakePHP 3.6.11
  2. Nginx 1.14.0
  3. MariaDB 10.1.35

Modifying CakePHP Settings

There is dotenv support which has been made available in your /config/bootstrap.php file. You can access and modify any settings you'd like to make by editing /config/.env. Do not make changes to either /config/app.php or /config/app.default.php as it is better to work off the .env file for any configuration changes.

The .env file has configuration options for:

  • General app settings
  • Cache control
  • Email transport
  • Database connection
  • Logging options
  • Session and Error level handling

MariaDB versus MySQL

MariaDB 10.1 is installed due to a bug with MySQL 5.7 that prevents it installing when building on Docker Hub. Ironically, if you build the image on your machine MySQL 5.7 builds fine so the issue, for whatever reason, only exists on Docker Hub. If you need MySQL 5.7 you could change the mariadb-server option to mysql-server by editing the Dockerfile and building the image yourself.

Accessing the Databases

The containers come with MariaDB pre-installed. During the Docker creation, two databases are installed for both production and any unit tests you need to run.

Production Database

Database: cakephp_live
Username: cakephp_live_user
Password: b5uF95fstJmhABD4is
Connection: DATABASE_URL exists in your /config/.env file with the full connection string to the production database.

Testing Database

Database: cakephp_test
Username: cakephp_test_user
Password: 4hiEKuzgFr54fyPVQJ
Connection: DATABASE_TEST_URL exists in your /config/.env file with the full connection string to the testing database.

Changing MySQL Passwords

If you'd like to change the password for the two default MySQL user accounts then run the following commands in MySQL - replace $PASSWORD with your new password for the account.

mysql> FLUSH PRIVILEGES;
mysql> ALTER USER 'cakephp_live_user'@'localhost' IDENTIFIED BY '$PASSWORD';
mysql> ALTER USER 'cakephp_test_user'@'localhost' IDENTIFIED BY '$PASSWORD';

Setting the MySQL Root Password

The MySQL root password has not been set in the Docker container. Please make sure to change this and set a password for your root MySQL account as it is not secure if left as is. You can follow the same method above to set a root password or you could run $ mysql_secure_installation in a terminal window in the Container Image which would completely secure your MySQL installation.

What is CakePHP?

CakePHP is an open source web application framework. It follows the Model-View-Controller (MVC) approach and is written in PHP, modelled after the concepts of Ruby on Rails, and distributed under the MIT License.

Quick reference