Deploy PHP app to docker container
- Make sure you have
dockeranddocker-composeinstalled. - Put your PHP application source code to
appdirectory. - Tune
./conf/php.iniif you need. - Fill
.envwith your settings. - Ensure your application to use hosts
dbandcachefor mysql and redis connections. - Have your application configured to use same credentials as
MYSQL_DATABASE,MYSQL_USER,MYSQL_PASSWORD. - Run
makewithindocker-phproot directory to build and run containers. - Read
Makefileto know yourmakeshortcuts.
When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables. Furthermore, it will execute files with extensions .sh, .sql and .sql.gz that are found in /docker-entrypoint-initdb.d. Files will be executed in alphabetical order. You can easily populate your mysql services by mounting a SQL dump into that directory and provide custom images with contributed data. SQL files will be imported by default to the database specified by the MYSQL_DATABASE variable.