From 4edf9418720494096e010d0d09f81482f2e173bf Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 02:43:23 +0300 Subject: [PATCH 01/20] rename php to php-fpm preparing to add php cli as part of the workspace container --- docker-compose.yml | 8 ++++---- php/Dockerfile-php-55 => php-fpm/Dockerfile-55 | 0 php/Dockerfile-php-56 => php-fpm/Dockerfile-56 | 0 php/Dockerfile-php-70 => php-fpm/Dockerfile-70 | 0 {php => php-fpm}/laravel.ini | 0 {php => php-fpm}/laravel.pool.conf | 0 6 files changed, 4 insertions(+), 4 deletions(-) rename php/Dockerfile-php-55 => php-fpm/Dockerfile-55 (100%) rename php/Dockerfile-php-56 => php-fpm/Dockerfile-56 (100%) rename php/Dockerfile-php-70 => php-fpm/Dockerfile-70 (100%) rename {php => php-fpm}/laravel.ini (100%) rename {php => php-fpm}/laravel.pool.conf (100%) diff --git a/docker-compose.yml b/docker-compose.yml index 549458d..50cb5e2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,12 +15,12 @@ services: links: - php -### PHP Container ########################################### +### PHP-FPM Container ####################################### - php: + php-fpm: build: - context: ./php - dockerfile: Dockerfile-php-70 + context: ./php-fpm + dockerfile: Dockerfile-70 volumes: - ../:/var/www/laravel - ./logs/php/:/usr/local/var/log diff --git a/php/Dockerfile-php-55 b/php-fpm/Dockerfile-55 similarity index 100% rename from php/Dockerfile-php-55 rename to php-fpm/Dockerfile-55 diff --git a/php/Dockerfile-php-56 b/php-fpm/Dockerfile-56 similarity index 100% rename from php/Dockerfile-php-56 rename to php-fpm/Dockerfile-56 diff --git a/php/Dockerfile-php-70 b/php-fpm/Dockerfile-70 similarity index 100% rename from php/Dockerfile-php-70 rename to php-fpm/Dockerfile-70 diff --git a/php/laravel.ini b/php-fpm/laravel.ini similarity index 100% rename from php/laravel.ini rename to php-fpm/laravel.ini diff --git a/php/laravel.pool.conf b/php-fpm/laravel.pool.conf similarity index 100% rename from php/laravel.pool.conf rename to php-fpm/laravel.pool.conf From 504c9c59d56f5c413b41f91bd6b1d238ed1d4f6b Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 02:46:27 +0300 Subject: [PATCH 02/20] Create workspace container the workspace container is based from Ubuntu 16.04 it includes PHP-CLI 7 - Git - cURL and Vim for now --- docker-compose.yml | 7 ++++++ workspace/Dockerfile | 51 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 workspace/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index 50cb5e2..5339783 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -126,4 +126,11 @@ services: links: - beanstalkd +### Workspace Container ##################################### + + workspace: + build: ./workspace + volumes_from: + - data + ### Add more Containers below ############################### diff --git a/workspace/Dockerfile b/workspace/Dockerfile new file mode 100644 index 0000000..c764aa0 --- /dev/null +++ b/workspace/Dockerfile @@ -0,0 +1,51 @@ +FROM ubuntu:16.04 + +MAINTAINER Mahmoud Zalt + +RUN DEBIAN_FRONTEND=noninteractive +RUN locale-gen en_US.UTF-8 +ENV LANGUAGE=en_US.UTF-8 +ENV LANG=en_US.UTF-8 +ENV LC_ALL=en_US.UTF-8 + +# Install some essential libraries +RUN apt-get update && apt-get install -y \ + software-properties-common \ + python-software-properties \ + autoconf \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkg-config + +# Install PHP-CLI 7 +RUN add-apt-repository -y ppa:ondrej/php +RUN apt-get update && apt-get install -y \ + php7.0-cli \ + php7.0-common \ + php7.0-curl \ + php7.0-json \ + php7.0-mbstring \ + php7.0-mcrypt \ + php7.0-mysql + +# Install some Tools +RUN apt-get install -y \ + git \ + curl \ + vim + +# Setup the Composer installer +RUN curl -s http://getcomposer.org/installer | php \ + && mv composer.phar /usr/local/bin/ \ + && alias composer='/usr/local/bin/composer.phar' + +# Clean up +RUN rm -r /var/lib/apt/lists/* + +ENTRYPOINT ["top", "-b"] + +WORKDIR /var/www/laravel + From efd062fd882702fe31d641033aafcae95574553a Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 02:54:23 +0300 Subject: [PATCH 03/20] fix linking containers to php-fpm instead of php --- docker-compose.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5339783..bd8d26c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,13 +7,13 @@ services: nginx: build: ./nginx volumes_from: - - php + - php-fpm volumes: - ./logs/nginx/:/var/log/nginx ports: - "80:80" links: - - php + - php-fpm ### PHP-FPM Container ####################################### @@ -52,7 +52,7 @@ services: MYSQL_PASSWORD: secret MYSQL_ROOT_PASSWORD: root links: - - php + - php-fpm ### PostgreSQL Container #################################### @@ -67,7 +67,7 @@ services: POSTGRES_USER: homestead POSTGRES_PASSWORD: secret links: - - php + - php-fpm ### MariaDB Container ####################################### @@ -83,7 +83,7 @@ services: MYSQL_PASSWORD: secret MYSQL_ROOT_PASSWORD: root links: - - php + - php-fpm ### Redis Container ######################################### @@ -94,7 +94,7 @@ services: ports: - "6379:6379" links: - - php + - php-fpm ### Memcached Container ##################################### @@ -105,7 +105,7 @@ services: ports: - "11211:11211" links: - - php + - php-fpm ### Beanstalkd Container #################################### @@ -115,7 +115,7 @@ services: - "11300:11300" privileged: true links: - - php + - php-fpm ### Beanstalkd-Console Container ############################ From 7dcf481d21b709d00b601cfb0ffff09fc2d299c8 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 02:54:35 +0300 Subject: [PATCH 04/20] install nano in the workspace container --- workspace/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index c764aa0..077e7a9 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -35,7 +35,8 @@ RUN apt-get update && apt-get install -y \ RUN apt-get install -y \ git \ curl \ - vim + vim \ + nano # Setup the Composer installer RUN curl -s http://getcomposer.org/installer | php \ From 97500508f51107bd80577964c2ebd2a2b8b5e07f Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 03:54:21 +0300 Subject: [PATCH 05/20] reformat the workspace Dockerfile --- workspace/Dockerfile | 50 +++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 077e7a9..d7de228 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -4,41 +4,33 @@ MAINTAINER Mahmoud Zalt RUN DEBIAN_FRONTEND=noninteractive RUN locale-gen en_US.UTF-8 + ENV LANGUAGE=en_US.UTF-8 ENV LANG=en_US.UTF-8 ENV LC_ALL=en_US.UTF-8 +ENV TERM xterm -# Install some essential libraries -RUN apt-get update && apt-get install -y \ - software-properties-common \ - python-software-properties \ - autoconf \ - file \ - g++ \ - gcc \ - libc-dev \ - make \ - pkg-config +# Install "software-properties-common" (for add-apt-repository) and add the "PHP 7" ppa +RUN apt-get update \ + && apt-get install -y software-properties-common \ + && add-apt-repository -y ppa:ondrej/php -# Install PHP-CLI 7 -RUN add-apt-repository -y ppa:ondrej/php -RUN apt-get update && apt-get install -y \ - php7.0-cli \ - php7.0-common \ - php7.0-curl \ - php7.0-json \ - php7.0-mbstring \ - php7.0-mcrypt \ - php7.0-mysql +# Install PHP-CLI 7 and some useful Tools +RUN apt-get update \ + && apt-get install -y \ + php7.0-cli \ + php7.0-common \ + php7.0-curl \ + php7.0-json \ + php7.0-mbstring \ + php7.0-mcrypt \ + php7.0-mysql \ + git \ + curl \ + vim \ + nano -# Install some Tools -RUN apt-get install -y \ - git \ - curl \ - vim \ - nano - -# Setup the Composer installer +# Install Composer RUN curl -s http://getcomposer.org/installer | php \ && mv composer.phar /usr/local/bin/ \ && alias composer='/usr/local/bin/composer.phar' From 51b6d4f8447dc01ff059ce8a0479f08f727312e4 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 04:38:46 +0300 Subject: [PATCH 06/20] update readme file (php section) --- README.md | 33 +++++++++++++++++---------------- workspace/Dockerfile | 3 ++- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 15f9d5a..2fbae60 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ docker-compose up nginx mysql redis - Easy switch between PHP versions: 7.0 - 5.6 - 5.5 ... - Choose your favorite database engine: MySQL - Postgres - Redis ... - Run your own combination of software's: Memcached - MariaDB ... -- Every software runs on a separate container: PHP - NGINX ... +- Every software runs on a separate container: PHP-FPM - NGINX ... - Easy to customize any container, with simple edit to the `dockerfile`. - All Images extends from an official base Image. (Trusted base Images). - Pre-configured Nginx for Laravel. @@ -78,7 +78,7 @@ docker-compose up nginx mysql redis ## Supported Containers -- PHP (7.0 - 5.6 - 5.5) +- PHP-FPM (7.0 - 5.6 - 5.5) - NGINX - MySQL - PostgreSQL @@ -88,6 +88,7 @@ docker-compose up nginx mysql redis - Beanstalkd - Beanstalkd Console - Data Volume +- Workspace (includes: `Git`, `Vim`, `nano`, `PHP-CLI 7.0`, `cURL`) >If you can't find your container, build it yourself and add it to this list. Contributions are welcomed :) @@ -139,7 +140,7 @@ Running a virtual Container is much faster than running a full virtual Machine. |-----------------------------------------------------------------------------------------|---------------------------------------------------------| | [Laravel](https://laravel.com/docs/master/installation) | [Laravel](https://laravel.com/docs/master/installation) | | [Git](https://git-scm.com/downloads) | [Git](https://git-scm.com/downloads) | -| [Docker Engine](https://docs.docker.com/engine/installation/linux/ubuntulinux/#install) | [Docker Toolbox](https://www.docker.com/toolbox) | +| [Docker Engine](https://docs.docker.com/engine/installation/linux/ubuntulinux) | [Docker Toolbox](https://www.docker.com/toolbox) | | [Docker Compose](https://docs.docker.com/compose/install) | | @@ -185,21 +186,21 @@ DB_HOST=xxx.xxx.xxx.xxx
*Make sure you are in the `docker` folder before running the `docker-compose` command.* -> Running PHP, NGINX, MySQL and Redis: +> Running PHP-FPM, NGINX, MySQL, Redis and the Data Containers: ```bash -docker-compose up -d php nginx mysql redis +docker-compose up -d nginx mysql redis ``` Note: you can choose your own combination of software's (containers), another example: -> Running PHP, NGINX, Postgres and Memcached: +> Running PHP-FPM, NGINX, Postgres, Memcached and the Data Containers: ```bash -docker-compose up -d php nginx postgres memcached +docker-compose up -d nginx postgres memcached ``` -Supported Containers: `nginx`, `mysql`, `redis`, `postgres`, `mariadb`, `memcached`, `beanstalkd`, `beanstalkd-console`, `data`, `php`. +Supported Containers: `nginx`, `mysql`, `redis`, `postgres`, `mariadb`, `memcached`, `beanstalkd`, `beanstalkd-console`, `data`, `php-fpm`, `workspace`.
3 - Open your browser and visit your `{Docker-IP}` address (`http://xxx.xxx.xxx.xxx`). @@ -284,26 +285,26 @@ To change the default PHP version: 1 - Open the `docker-compose.yml`. -2 - Search for `Dockerfile-php-70` in the PHP container section. +2 - Search for `Dockerfile-70` in the PHP container section. 3 - Change the version number.
-Example to select version 5.6 instead of 7.0 you have to replace `Dockerfile-php-70` with `Dockerfile-php-56`. +Example to select version 5.6 instead of 7.0 you have to replace `Dockerfile-70` with `Dockerfile-56`. Sample: ```txt -php: +php-fpm: build: - context: ./php - dockerfile: Dockerfile-php-70 + context: ./php-fpm + dockerfile: Dockerfile-70 ``` Supported Versions: -- For (PHP 7.0.*) use `Dockerfile-php-70` -- For (PHP 5.6.*) use `Dockerfile-php-56` -- For (PHP 5.5.*) use `Dockerfile-php-55` +- For (PHP 7.0.*) use `Dockerfile-70` +- For (PHP 5.6.*) use `Dockerfile-56` +- For (PHP 5.5.*) use `Dockerfile-55` 4 - Finally rebuild the container diff --git a/workspace/Dockerfile b/workspace/Dockerfile index d7de228..c93c7f6 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -6,8 +6,9 @@ RUN DEBIAN_FRONTEND=noninteractive RUN locale-gen en_US.UTF-8 ENV LANGUAGE=en_US.UTF-8 -ENV LANG=en_US.UTF-8 ENV LC_ALL=en_US.UTF-8 +ENV LC_CTYPE=UTF-8 +ENV LANG=en_US.UTF-8 ENV TERM xterm # Install "software-properties-common" (for add-apt-repository) and add the "PHP 7" ppa From 377f24fe2b92842b67d6cad45fec24b37759b4af Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 06:28:31 +0300 Subject: [PATCH 07/20] keep workspace container alive with tty --- docker-compose.yml | 2 ++ workspace/Dockerfile | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index bd8d26c..eb1f0c7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,7 @@ services: - ./logs/nginx/:/var/log/nginx ports: - "80:80" + - "443:443" links: - php-fpm @@ -132,5 +133,6 @@ services: build: ./workspace volumes_from: - data + tty: true ### Add more Containers below ############################### diff --git a/workspace/Dockerfile b/workspace/Dockerfile index c93c7f6..9223b2c 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -37,9 +37,8 @@ RUN curl -s http://getcomposer.org/installer | php \ && alias composer='/usr/local/bin/composer.phar' # Clean up -RUN rm -r /var/lib/apt/lists/* - -ENTRYPOINT ["top", "-b"] +RUN apt-get clean \ + && rm -r /var/lib/apt/lists/* WORKDIR /var/www/laravel From 6eb3a9bd5f8f9a6c3c1eaa926bf80093237086ac Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 06:29:33 +0300 Subject: [PATCH 08/20] fix nginx not connecting to php port 9000 --- nginx/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx/Dockerfile b/nginx/Dockerfile index eb11493..495382f 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -5,7 +5,7 @@ MAINTAINER Mahmoud Zalt ADD nginx.conf /etc/nginx/ ADD laravel.conf /etc/nginx/sites-available/ -RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf +RUN echo "upstream php-upstream { server php-fpm:9000; }" > /etc/nginx/conf.d/upstream.conf RUN usermod -u 1000 www-data From 1574231a8044560761e647b87cfcd18375034f62 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 07:11:49 +0300 Subject: [PATCH 09/20] replace ubuntu 16.04 with lighter ubuntu version --- workspace/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 9223b2c..06fdb8c 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:16.04 +FROM phusion/baseimage:latest MAINTAINER Mahmoud Zalt From 4d8a798224e9267ab999aa764686c6bd861e9005 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 07:13:19 +0300 Subject: [PATCH 10/20] Create Application Container to hold App code --- README.md | 17 ++++++----------- application/Dockerfile | 7 +++++++ docker-compose.yml | 42 +++++++++++++++++++++++++----------------- 3 files changed, 38 insertions(+), 28 deletions(-) create mode 100644 application/Dockerfile diff --git a/README.md b/README.md index 2fbae60..2660f15 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,8 @@ docker-compose up nginx mysql redis - Memcached - Beanstalkd - Beanstalkd Console -- Data Volume +- Data Volume *(Databases Data Container)* +- Application *(Application Code Container)* - Workspace (includes: `Git`, `Vim`, `nano`, `PHP-CLI 7.0`, `cURL`) >If you can't find your container, build it yourself and add it to this list. Contributions are welcomed :) @@ -186,21 +187,15 @@ DB_HOST=xxx.xxx.xxx.xxx
*Make sure you are in the `docker` folder before running the `docker-compose` command.* -> Running PHP-FPM, NGINX, MySQL, Redis and the Data Containers: +**Example:** Running NGINX, MySQL, Redis and the workspace: ```bash -docker-compose up -d nginx mysql redis +docker-compose up -d nginx mysql redis Workspace ``` +*Note: the PHP-FPM, Application and Data Containers will automatically run.* -Note: you can choose your own combination of software's (containers), another example: -> Running PHP-FPM, NGINX, Postgres, Memcached and the Data Containers: - -```bash -docker-compose up -d nginx postgres memcached -``` - -Supported Containers: `nginx`, `mysql`, `redis`, `postgres`, `mariadb`, `memcached`, `beanstalkd`, `beanstalkd-console`, `data`, `php-fpm`, `workspace`. +Supported Containers: `nginx`, `workspace`, `mysql`, `redis`, `postgres`, `mariadb`, `memcached`, `beanstalkd`, `beanstalkd-console`, `data`, `php-fpm`, `application`.
3 - Open your browser and visit your `{Docker-IP}` address (`http://xxx.xxx.xxx.xxx`). diff --git a/application/Dockerfile b/application/Dockerfile new file mode 100644 index 0000000..33c1966 --- /dev/null +++ b/application/Dockerfile @@ -0,0 +1,7 @@ +FROM debian:jessie + +MAINTAINER Mahmoud Zalt + +WORKDIR /var/www/laravel + +CMD ["true"] diff --git a/docker-compose.yml b/docker-compose.yml index eb1f0c7..b0d7265 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,33 +2,27 @@ version: '2' services: -### Nginx Server Container ################################## - - nginx: - build: ./nginx - volumes_from: - - php-fpm - volumes: - - ./logs/nginx/:/var/log/nginx - ports: - - "80:80" - - "443:443" - links: - - php-fpm - ### PHP-FPM Container ####################################### php-fpm: build: context: ./php-fpm dockerfile: Dockerfile-70 + volumes_from: + - application volumes: - - ../:/var/www/laravel - ./logs/php/:/usr/local/var/log expose: - "9000" -### DATA Container ########################################## +### Laravel Application Code Container ###################### + + application: + build: ./application + volumes: + - ../:/var/www/laravel + +### Databases Data Container ################################ data: build: ./data @@ -39,6 +33,20 @@ services: - /var/lib/redis - /var/lib/memcached +### Nginx Server Container ################################## + + nginx: + build: ./nginx + volumes_from: + - application + volumes: + - ./logs/nginx/:/var/log/nginx + ports: + - "80:80" + - "443:443" + links: + - php-fpm + ### MySQL Container ######################################### mysql: @@ -132,7 +140,7 @@ services: workspace: build: ./workspace volumes_from: - - data + - application tty: true ### Add more Containers below ############################### From 5ef193d55baf0e41809a9bbacb8a1ee68f22875f Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 07:16:20 +0300 Subject: [PATCH 11/20] update readme --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2660f15..a12fb8d 100644 --- a/README.md +++ b/README.md @@ -52,10 +52,10 @@ LaraDock strives to make the development experience easier. It contains pre-packaged Docker Images that provides you a wonderful development environment without requiring you to install PHP, NGINX, MySQL, REDIS, and any other software on your local machine. -**Usage Overview:** Run `NGINX`, `MySQL` and `Redis`. +**Usage Overview:** Run `NGINX` and `MySQL`. ```shell -docker-compose up nginx mysql redis +docker-compose up nginx mysql ``` @@ -225,6 +225,12 @@ sudo chmod -R 777 storage && sudo chmod -R 777 bootstrap/cache ```bash docker ps ``` +You can also use the this command if you want to see only this project containers: + +```bash +docker-compose ps +``` +
From 16a1041ef5f716d81513d8a884142709ee4e837e Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 07:53:14 +0300 Subject: [PATCH 12/20] clean the workspace container --- workspace/Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 06fdb8c..9220764 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -37,8 +37,7 @@ RUN curl -s http://getcomposer.org/installer | php \ && alias composer='/usr/local/bin/composer.phar' # Clean up -RUN apt-get clean \ - && rm -r /var/lib/apt/lists/* +RUN apt-get autoclean && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* WORKDIR /var/www/laravel - From 2c05c87400ad924d65e313c6d744966601fdd51e Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 07:56:12 +0300 Subject: [PATCH 13/20] update the logs section --- README.md | 11 +++++++++-- docker-compose.yml | 6 ++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a12fb8d..26d7b04 100644 --- a/README.md +++ b/README.md @@ -374,7 +374,7 @@ DB_HOST=xxx.xxx.xxx.xxx Optionally you can define the server name in the nginx config file, like this: -``` +```conf server_name laravel.dev; ``` @@ -384,7 +384,14 @@ server_name laravel.dev;
#### View the Log files -The Log files are stored in the `docker/logs` directory. +The Nginx Log file is stored in the `logs/nginx` directory. + +However to view the logs of all the other containers (MySQL, PHP-FPM,...) you can run this: + +```bash +docker logs {container-id} +``` + diff --git a/docker-compose.yml b/docker-compose.yml index b0d7265..bc7ae53 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,8 +10,6 @@ services: dockerfile: Dockerfile-70 volumes_from: - application - volumes: - - ./logs/php/:/usr/local/var/log expose: - "9000" @@ -126,7 +124,7 @@ services: links: - php-fpm -### Beanstalkd-Console Container ############################ +### Beanstalkd Console Container ############################ beanstalkd-console: build: ./beanstalkd-console @@ -135,7 +133,7 @@ services: links: - beanstalkd -### Workspace Container ##################################### +### Workspace Utilities Container ########################### workspace: build: ./workspace From a69681b07cbc69ec20fbbba5d147948e9facf8f5 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 07:58:33 +0300 Subject: [PATCH 14/20] install the php zip extention in the workspace --- workspace/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 9220764..efaf59b 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -26,6 +26,7 @@ RUN apt-get update \ php7.0-mbstring \ php7.0-mcrypt \ php7.0-mysql \ + php7.0-zip \ git \ curl \ vim \ From fb4fcdcb2396525627ba9b8a784f914886f4e003 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 08:07:54 +0300 Subject: [PATCH 15/20] Install the Laravel Installer in the workspace container --- workspace/Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index efaf59b..4eb0e4a 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -37,6 +37,10 @@ RUN curl -s http://getcomposer.org/installer | php \ && mv composer.phar /usr/local/bin/ \ && alias composer='/usr/local/bin/composer.phar' +# Install Laravel Installer +RUN composer.phar global require "laravel/installer" \ + && export PATH="$PATH:$HOME/.composer/vendor/bin" + # Clean up RUN apt-get autoclean && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* From 07a07ab3ac750100b515dc52492d3e80644d8dc0 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 08:23:53 +0300 Subject: [PATCH 16/20] install php xml in the workspace container --- workspace/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 4eb0e4a..40603ed 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -23,6 +23,7 @@ RUN apt-get update \ php7.0-common \ php7.0-curl \ php7.0-json \ + php7.0-xml \ php7.0-mbstring \ php7.0-mcrypt \ php7.0-mysql \ From 66f08a4f60cf024ab03b3204a762fec7104c34a9 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 08:40:08 +0300 Subject: [PATCH 17/20] fix .bashrc exports and alises --- workspace/Dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 40603ed..bff9326 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -36,11 +36,14 @@ RUN apt-get update \ # Install Composer RUN curl -s http://getcomposer.org/installer | php \ && mv composer.phar /usr/local/bin/ \ - && alias composer='/usr/local/bin/composer.phar' + && echo "alias composer='/usr/local/bin/composer.phar'" >> ~/.bashrc -# Install Laravel Installer +# Install the Laravel Installer RUN composer.phar global require "laravel/installer" \ - && export PATH="$PATH:$HOME/.composer/vendor/bin" + && echo "export PATH='$PATH:$HOME/.composer/vendor/bin'" >> ~/.bashrc + +# Source the bashrc to apply updates +RUN . ~/.bashrc # Clean up RUN apt-get autoclean && apt-get clean \ From 71719968437d5cc243aa488d4142a29937bb4a1b Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 09:05:45 +0300 Subject: [PATCH 18/20] replace composer path --- workspace/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index bff9326..e604d5c 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -40,7 +40,7 @@ RUN curl -s http://getcomposer.org/installer | php \ # Install the Laravel Installer RUN composer.phar global require "laravel/installer" \ - && echo "export PATH='$PATH:$HOME/.composer/vendor/bin'" >> ~/.bashrc + && echo "export PATH='~/.composer/vendor/bin:$PATH'" >> ~/.bashrc # Source the bashrc to apply updates RUN . ~/.bashrc From 3b2831bf1dba819807c91a4b38d2d1c1c7dfa8a1 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 10:25:54 +0300 Subject: [PATCH 19/20] add alias for phpunit in the .bashrc --- README.md | 4 ++-- workspace/Dockerfile | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 26d7b04..e0da3d8 100644 --- a/README.md +++ b/README.md @@ -389,7 +389,7 @@ The Nginx Log file is stored in the `logs/nginx` directory. However to view the logs of all the other containers (MySQL, PHP-FPM,...) you can run this: ```bash -docker logs {container-id} +docker logs {container-name} ``` @@ -454,7 +454,7 @@ composer require predis/predis:^1.0 2 - enter any container using: ```bash -docker exec -it {container-name-or-id} bash +docker exec -it {container-name} bash ``` 3 - to exit a container, type `exit`. diff --git a/workspace/Dockerfile b/workspace/Dockerfile index e604d5c..ee0605b 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -42,7 +42,10 @@ RUN curl -s http://getcomposer.org/installer | php \ RUN composer.phar global require "laravel/installer" \ && echo "export PATH='~/.composer/vendor/bin:$PATH'" >> ~/.bashrc -# Source the bashrc to apply updates +# Add an alias for PHPUnit +RUN echo "alias phpunit='./vendor/bin/phpunit'" >> ~/.bashrc + +# Source the bash RUN . ~/.bashrc # Clean up From 5aa01b17572bdfe40b45e847d6eefd8ce5aab041 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Wed, 18 May 2016 11:12:21 +0300 Subject: [PATCH 20/20] add the new way of using LaraDock in the readme --- README.md | 72 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e0da3d8..da0e9bd 100644 --- a/README.md +++ b/README.md @@ -87,9 +87,10 @@ docker-compose up nginx mysql - Memcached - Beanstalkd - Beanstalkd Console +- Workspace (includes: Composer, PHP7-CLI , Laravel Installer, Git, Vim, Nano, cURL) - Data Volume *(Databases Data Container)* - Application *(Application Code Container)* -- Workspace (includes: `Git`, `Vim`, `nano`, `PHP-CLI 7.0`, `cURL`) + >If you can't find your container, build it yourself and add it to this list. Contributions are welcomed :) @@ -148,19 +149,60 @@ Running a virtual Container is much faster than running a full virtual Machine. ## Installation -1 - Clone the `LaraDock` repository, in any of your `Laravel` projects: +#### A] In existing Laravel Projects: + +1 - Clone the `LaraDock` repository, inside your `Laravel` project root direcotry: ```bash -git clone https://github.com/LaraDock/laradock.git docker +git submodule add https://github.com/LaraDock/laradock.git ``` -You can use `git submodule add` instead of `git clone` if you are already using Git for your Laravel project *(Recommended)*: +2 - That's it, jump to the Usage section now. + +*If you are not already using Git for your Laravel project, you can use `git clone` instead of `git submodule`.* + + +#### B] Starting from scratch (we will install Laravel): + +*If you don't have any Laravel project yet, and you want to start your Laravel project with Docker.* + +1 - Clone the `LaraDock` repository anywhere on your machine: ```bash -git submodule add https://github.com/LaraDock/laradock.git docker +git clone https://github.com/LaraDock/laradock.git ``` ->These commands should create a `docker` folder, on the root directory of your Laravel project. +2 - Go to the Uage section below and do the steps 1 and 3 then come back here. + +3 - Enter the Workspace container. (assuming you have the Workspace container running): + +```bash +docker exec -it {Workspace-Container-Name} bash +``` +Replace `{Workspace-Container-Name}` with your Workspace container name. To get the name type `docker-compose ps` and copy it. + +4 - Install Laravel anyway you like. + +Example using the Laravel Installer: + +```bash +laravel new my-cool-app +``` +For more about this check out this [link](https://laravel.com/docs/master#installing-laravel). + +5 - Edit `docker-compose.yml` to Map the new application path: + +By default LaraDock assumes the Laravel application is living in the parent directory of the laradock folder. + +Since the new Laravel application is in the `my-cool-app` folder, we should replace `../:/var/www/laravel` with `../my-cool-app/:/var/www/laravel`, as follow: + +```yaml + application: + build: ./application + volumes: + - ../my-cool-app/:/var/www/laravel +``` +6 - Finallt go to the Usage section below again and do steps 2 and 4. @@ -168,14 +210,14 @@ git submodule add https://github.com/LaraDock/laradock.git docker ## Usage -0 - For **Windows & MAC** users only: make sure you have a running Docker Virtual Host on your machine. +1 - For **Windows & MAC** users only: make sure you have a running Docker Virtual Host on your machine. (**Linux** users don't need a Virtual Host, so skip this step).
[How to run a Docker Virtual Host?](#Run-Docker-Virtual-Host)
-1 - Open your Laravel's `.env` file and set the `DB_HOST` to your `{Docker-IP}`: +2 - Open your Laravel's `.env` file and set the `DB_HOST` to your `{Docker-IP}`: ```env DB_HOST=xxx.xxx.xxx.xxx @@ -183,22 +225,22 @@ DB_HOST=xxx.xxx.xxx.xxx [How to find my Docker IP Address?](#Find-Docker-IP-Address)
-2 - Run the Containers, (you can select the software's (containers) that you wish to run) +3 - Run the Containers, (you can select the software's (containers) that you wish to run)
-*Make sure you are in the `docker` folder before running the `docker-compose` command.* +*Make sure you are in the `laradock` folder before running the `docker-compose` command.* -**Example:** Running NGINX, MySQL, Redis and the workspace: +**Example:** Running NGINX, MySQL, Redis and the Workspace: ```bash -docker-compose up -d nginx mysql redis Workspace +docker-compose up -d nginx mysql redis workspace ``` *Note: the PHP-FPM, Application and Data Containers will automatically run.* -Supported Containers: `nginx`, `workspace`, `mysql`, `redis`, `postgres`, `mariadb`, `memcached`, `beanstalkd`, `beanstalkd-console`, `data`, `php-fpm`, `application`. +Supported Containers: `workspace`, `nginx`, `mysql`, `redis`, `postgres`, `mariadb`, `memcached`, `beanstalkd`, `beanstalkd-console`, `data`, `php-fpm`, `application`.
-3 - Open your browser and visit your `{Docker-IP}` address (`http://xxx.xxx.xxx.xxx`). +4 - Open your browser and visit your `{Docker-IP}` address (`http://xxx.xxx.xxx.xxx`).
@@ -314,7 +356,7 @@ Supported Versions: docker-compose build php ``` -For more details visit the [official PHP docker images](https://hub.docker.com/_/php/). +For more details about the PHP base image, visit the [official PHP docker images](https://hub.docker.com/_/php/).