27

GitHub - kibria4/docker-compose-php7.4: A Docker Compose Setup to help get start...

 3 years ago
source link: https://github.com/kibria4/docker-compose-php7.4
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Docker Compose - Nginx, PHP 7.4-fpm, Postgres

A full docker compose setup for your PHP project for local development. Originally set up to work for Symfony 4+ projects, but can be tweaked to work in any PHP project. Thanks to https://github.com/ineat/docker-php-nginx-postgres-composer for pointing me in the right direction. I made some slight tweaks to use PHP 7.4-fpm easily and using Postgres for database.

Prerequisites

  • Docker v1.13.0+
  • Docker Compose (should come with Docker)

Installing Docker

Quick Guide:

  • Clone this into your project root folder
  • Go to .docker/nginx/default.conf and update the root folder AFTER /var/www/html (the public folder to access in browser, i.e. for Symfony it is "public", so /var/www/html/public)
  • Go to .docker/php/php.ini and add configuration specific to your project needs
  • Go to .docker/Dockerfile and on the same line as "install-php-extensions ...", add the extensions you need (list of available extensions here: https://github.com/mlocati/docker-php-extension-installer). You can also change the PHP version at the top. I set default to latest stable FPM. Currently only tested with PHP FPM.
  • Go to docker-compose.yaml and check all required services are enabled. I have added PG Admin, Redis, RabbitMQ and Mailcatcher but commented out. Uncomment if you want to use this
  • In terminal, "cd" to project root, and then run: docker-compose up -d
  • In your browser, go to localhost

TODO for this project

  • Add support for other databases
  • Show examples of using this in other popular PHP projects, such as Laravel, WordPress, etc

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK