├── README.md ├── docker-compose.yml ├── index.php ├── nginx ├── Dockerfile └── default.conf └── php └── Dockerfile /README.md: -------------------------------------------------------------------------------- 1 | # Pre-requisites 2 | 3 | You must have Docker installed for this code to work! Check the [Installation Guide](https://docs.docker.com/engine/installation/) if you haven't got it installed. 4 | 5 | It contains a basic LEMP stack running with Docker, intented to be used for local web development. 6 | 7 | ## Get started 8 | 9 | Clone the project and run docker-compose 10 | 11 | ```bash 12 | git clone https://github.com/jivoi/php-development-in-docker.git 13 | cd php-development-in-docker 14 | docker-compose up -d 15 | docker-machine ip default 16 | docker-compose -d down 17 | ``` 18 | 19 | ## Description 20 | 21 | The different containers are described in [`docker-compose.yml`](https://github.com/jivoi/php-development-in-docker/blob/master/docker-compose.yml). 22 | 23 | There are 6 of them: 24 | 25 | - a container for Nginx 26 | - a container for PHP-FPM 27 | - a container for MySQL 28 | - a container for phpMyAdmin 29 | - a container to make MySQL data persistent 30 | - a container for the application code 31 | 32 | All of them are using official images. 33 | 34 | The current directory is mounted into the one served by Nginx on the container, so any update to the code is available without having to rebuild the container. 35 | 36 | The MySQL data sits in its own directory mounted into its own container to make it persistent. 37 | 38 | The application is available on the port 80 of the host machine. 39 | 40 | phpMyAdmin is available on port 8080. 41 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | nginx: 2 | build: ./nginx/ 3 | ports: 4 | - 80:80 5 | links: 6 | - php 7 | volumes_from: 8 | - app 9 | 10 | php: 11 | build: ./php/ 12 | expose: 13 | - 9000 14 | links: 15 | - mysql 16 | volumes_from: 17 | - app 18 | 19 | app: 20 | image: php:7.0-fpm 21 | volumes: 22 | - .:/var/www/html 23 | command: "true" 24 | 25 | mysql: 26 | image: mysql:latest 27 | volumes_from: 28 | - data 29 | environment: 30 | MYSQL_ROOT_PASSWORD: secret 31 | MYSQL_DATABASE: project 32 | MYSQL_USER: project 33 | MYSQL_PASSWORD: project 34 | 35 | data: 36 | image: mysql:latest 37 | volumes: 38 | - /var/lib/mysql 39 | command: "true" 40 | 41 | phpmyadmin: 42 | image: phpmyadmin/phpmyadmin 43 | ports: 44 | - 8080:80 45 | links: 46 | - mysql 47 | environment: 48 | PMA_HOST: mysql -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |There are no tables in database \"{$database}\".
"; 17 | } else { 18 | echo "Database \"{$database}\" has the following tables:
"; 19 | echo "