From 2ed09f42ca38d293e0350fef64bb891bd6bc162d Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Mon, 31 Oct 2016 19:28:25 -0400 Subject: [PATCH 1/7] change workspace and php-fpm work directories making them compatible with multiple projects --- php-fpm/Dockerfile-56 | 2 +- php-fpm/Dockerfile-70 | 2 +- workspace/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/php-fpm/Dockerfile-56 b/php-fpm/Dockerfile-56 index 15996aae..1c811492 100644 --- a/php-fpm/Dockerfile-56 +++ b/php-fpm/Dockerfile-56 @@ -142,7 +142,7 @@ RUN rm -r /var/lib/apt/lists/* RUN usermod -u 1000 www-data -WORKDIR /var/www/laravel +WORKDIR /var/www CMD ["php-fpm"] diff --git a/php-fpm/Dockerfile-70 b/php-fpm/Dockerfile-70 index e8b38088..2e87c576 100644 --- a/php-fpm/Dockerfile-70 +++ b/php-fpm/Dockerfile-70 @@ -153,7 +153,7 @@ RUN rm -r /var/lib/apt/lists/* RUN usermod -u 1000 www-data -WORKDIR /var/www/laravel +WORKDIR /var/www CMD ["php-fpm"] diff --git a/workspace/Dockerfile b/workspace/Dockerfile index d73a0e93..d0315eef 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -246,4 +246,4 @@ RUN apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Set default work directory -WORKDIR /var/www/laravel +WORKDIR /var/www From 5da40586137288b8ef3255ede1ae11ee8ab861c8 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Mon, 31 Oct 2016 19:28:47 -0400 Subject: [PATCH 2/7] delete the drupal sample nginx config file --- nginx/sites/framework-examples/drupal_8.conf | 57 -------------------- 1 file changed, 57 deletions(-) delete mode 100644 nginx/sites/framework-examples/drupal_8.conf diff --git a/nginx/sites/framework-examples/drupal_8.conf b/nginx/sites/framework-examples/drupal_8.conf deleted file mode 100644 index fea06905..00000000 --- a/nginx/sites/framework-examples/drupal_8.conf +++ /dev/null @@ -1,57 +0,0 @@ -server { - listen 80; - listen [::]:80; - - #domain name - server_name drupal8.dev; - - #file document root. This has to match one of the volumes in docer-composer.yml - root /var/www/drupal8; - - # This is the full path to your index file - index index.php index.html index.htm; - - ## serve imagecache files directly or redirect to drupal if they do not exist. - location ~* files/styles { - access_log off; - expires 30d; - try_files $uri @drupal; - } - - ## serve imagecache files directly or redirect to drupal if they do not exist. - location ~* ^.+.(xsl|xml)$ { - access_log off; - expires 1d; - try_files $uri @drupal; - } - - ## Images and static content is treated different - location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ { - access_log off; - expires 30d; - } - - location / { - index index.php; - # This is cool because no php is touched for static content - try_files $uri $uri/ @rewrite; - expires max; - } - - location @drupal { - rewrite ^/(.*)$ /index.php?q=$1 last; - } - - location @rewrite { - # Some modules enforce no slash (/) at the end of the URL - # Else this rewrite block wouldn't be needed (GlobalRedirect) - rewrite ^/(.*)$ /index.php?q=$1; - } - - location ~ .php$ { - fastcgi_pass php-upstream; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; - } -} From 658d4e7532e93ce248cef5b33434434b78e50fa9 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Mon, 31 Oct 2016 19:30:12 -0400 Subject: [PATCH 3/7] add root access section to mysql docs --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index cc84aa8e..7c926da6 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ Laradock is configured to run Laravel Apps by default, and it can be modifyed to - [Cron jobs](#CronJobs) - [Access workspace via ssh](#Workspace-ssh) - [MySQL access from host](#MySQL-access-from-host) + - [MySQL root access](#MySQL-root-access) - [Use custom Domain](#Use-custom-Domain) - [Enable Global Composer Build Install](#Enable-Global-Composer-Build-Install) - [Install Prestissimo](#Install-Prestissimo) @@ -1096,6 +1097,21 @@ ports: - "3306:3306" ``` + +### MySQL root access + +The default username and password for the root mysql user are `root` and `root `. + +1 - Enter the mysql contaier: `docker-compose exec mysql bash`. + +2 - Enter mysql: `mysql -uroot -proot` for non root access use `mysql -uhomestead -psecret`. + +3 - See all users: `SELECT User FROM mysql.user;` + +4 - Run any commands `show databases`, `show tables`, `select * from.....`. + + + ### Use custom Domain (instead of the Docker IP) From 28130c5907c0f72334b9f9e3e2f73353adfea7b7 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Mon, 31 Oct 2016 19:31:15 -0400 Subject: [PATCH 4/7] delete site_a and site_b nginx config samples --- nginx/sites/site_a.conf | 28 ---------------------------- nginx/sites/site_b.conf | 28 ---------------------------- 2 files changed, 56 deletions(-) delete mode 100644 nginx/sites/site_a.conf delete mode 100644 nginx/sites/site_b.conf diff --git a/nginx/sites/site_a.conf b/nginx/sites/site_a.conf deleted file mode 100644 index 6bd32690..00000000 --- a/nginx/sites/site_a.conf +++ /dev/null @@ -1,28 +0,0 @@ -server { - - listen 80; - listen [::]:80; - - server_name site_a; - root /var/www/site_a/public; - index index.php index.html index.htm; - - location / { - try_files $uri $uri/ /index.php$is_args$args; - } - - location ~ \.php$ { - try_files $uri /index.php =404; - fastcgi_pass php-upstream; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; - } - - location ~ /\.ht { - deny all; - } -} - - - diff --git a/nginx/sites/site_b.conf b/nginx/sites/site_b.conf deleted file mode 100644 index e1539cd1..00000000 --- a/nginx/sites/site_b.conf +++ /dev/null @@ -1,28 +0,0 @@ -server { - - listen 80; - listen [::]:80; - - server_name site_b; - root /var/www/site_b/public; - index index.php index.html index.htm; - - location / { - try_files $uri $uri/ /index.php$is_args$args; - } - - location ~ \.php$ { - try_files $uri /index.php =404; - fastcgi_pass php-upstream; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; - } - - location ~ /\.ht { - deny all; - } -} - - - From 739cc31f4c5080f43e0b872d0f5317374c2a4419 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Mon, 31 Oct 2016 19:49:48 -0400 Subject: [PATCH 5/7] change app mapping directory from www/laravel to www also add sample to show facilitate setup for multiple sites --- docker-compose.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 13d71a10..54ce8d98 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,14 @@ version: '2' services: +### Applications Code Container ###################### + + volumes_source: + image: tianon/true + volumes: + - ../:/var/www +# - ../sample/:/var/www/sample + ### Workspace Utilities Container ########################### workspace: @@ -288,19 +296,13 @@ services: links: - php-fpm -### Laravel Application Code Container ###################### - - volumes_source: - image: tianon/true - volumes: - - ../:/var/www/laravel - ### Databases Data Container ################################ volumes_data: image: tianon/true volumes: - ./data/mysql:/var/lib/mysql + - ./databases:/docker-entrypoint-initdb.d - ./data/postgres:/var/lib/postgresql/data - ./data/memcached:/var/lib/memcached - ./data/redis:/data From dbee864d4488a4ef5c011be4a3397f34617b3e4a Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Mon, 31 Oct 2016 19:50:30 -0400 Subject: [PATCH 6/7] rename laravel.conf to default and add sample conf --- nginx/sites/{laravel.conf => default.conf} | 4 ++-- nginx/sites/sample.conf.example | 28 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) rename nginx/sites/{laravel.conf => default.conf} (89%) create mode 100644 nginx/sites/sample.conf.example diff --git a/nginx/sites/laravel.conf b/nginx/sites/default.conf similarity index 89% rename from nginx/sites/laravel.conf rename to nginx/sites/default.conf index a40a7f14..d5058bd5 100644 --- a/nginx/sites/laravel.conf +++ b/nginx/sites/default.conf @@ -3,8 +3,8 @@ server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; - server_name laravel; - root /var/www/laravel/public; + server_name laradock; + root /var/www/public; index index.php index.html index.htm; location / { diff --git a/nginx/sites/sample.conf.example b/nginx/sites/sample.conf.example new file mode 100644 index 00000000..e6520e59 --- /dev/null +++ b/nginx/sites/sample.conf.example @@ -0,0 +1,28 @@ +server { + + listen 80; + listen [::]:80; + + server_name sample.dev; + root /var/www/sample/public; + index index.php index.html index.htm; + + location / { + try_files $uri $uri/ /index.php$is_args$args; + } + + location ~ \.php$ { + try_files $uri /index.php =404; + fastcgi_pass php-upstream; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + + location ~ /\.ht { + deny all; + } +} + + + From 66723c0278994e126e79bd7a16474319ccd0c535 Mon Sep 17 00:00:00 2001 From: Mahmoud Zalt Date: Mon, 31 Oct 2016 20:30:34 -0400 Subject: [PATCH 7/7] update the doc to support multiple projects --- README.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 7c926da6..8a1ea1e4 100644 --- a/README.md +++ b/README.md @@ -207,17 +207,22 @@ What's better than a **Demo Video**: ## Installation +Choose the setup the best suits your needs. -Clone the `LaraDock` repository: +#### A) Setup for Single Project: +*(In case you want a Docker environment for each project)* -**A)** If you already have a Laravel project, clone this repository on your `Laravel` root directory: +##### A.1) Setup environment in existing Project: +*(In case you already have a project, and you want to setup an environemnt to run it)* + +1 - Clone this repository on your project root directory: ```bash git submodule add https://github.com/LaraDock/laradock.git ``` ->If you are not already using Git for your Laravel project, you can use `git clone` instead of `git submodule`. +>If you are not already using Git for your PHP project, you can use `git clone` instead of `git submodule`. -Note: In this case the folder structure will be like this (recommended): +Note: In this case the folder structure will be like this: ``` - project1 @@ -226,9 +231,10 @@ Note: In this case the folder structure will be like this (recommended): - laradock ``` -
+##### A.2) Setup environment first then create project: +*(In case you don't have a project, and you want to create your project inside the Docker environment)* -**B)** If you don't have a Laravel project, and you want to install Laravel from Docker, clone this repo anywhere on your machine: +1 - Clone this repository anywhere on your machine: ```bash git clone https://github.com/LaraDock/laradock.git @@ -238,11 +244,54 @@ Note: In this case the folder structure will be like this: ``` - projects - laradock - - project1 - - project2 + - myProject ``` -**Note:** if you are using this folder structure don't forget to edit the `docker-compose.yml` file to map to your Laravel directory once you have it (example: `- ../project1/:/var/www/laravel`). "You will need to stop and re-run your docker-compose command for the changes to take place". +2 - Edit the `docker-compose.yml` file to map to your project directory once you have it (example: `- ../myProject:/var/www`). + +3 - Stop and re-run your docker-compose command for the changes to take place. + +``` +docker-compose stop && docker-compose up -d XXXX YYYY ZZZZ .... +``` + + +#### B) Setup for Multiple Projects: + +1 - Clone this repository anywhere on your machine: + +```bash +git clone https://github.com/LaraDock/laradock.git +``` + +2 - Edit the `docker-compose.yml` file to map to your projects directories: + +``` + volumes_source: + image: tianon/true + volumes: + - ../project1/:/var/www/project1 + - ../project2/:/var/www/project2 +``` + +3 - You can access all sites by visiting `http://localhost/project1/public` and `http://localhost/project2/public` but of course that's not very useful so let's setup nginx quickly. + + +4 - Go to `nginx/sites` and copy `sample.conf.example` to `project1.conf` then to `project2.conf` + +5 - Open the `project1.conf` file and edit the `server_name` and the `root` as follow: + +``` + server_name project1.dev; + root /var/www/project1/public; +``` +Do the same for each project `project2.conf`, `project3.conf`,... + +6 - Create your project Databases **To Be Continue..** + + + + ## Usage @@ -268,7 +317,7 @@ If you are using **Docker Toolbox** (VM), do one of the following: **Example:** Running NGINX and MySQL: ```bash -docker-compose up -d nginx mysql +docker-compose up -d nginx mysql ``` **Note**: The `workspace` and `php-fpm` will run automatically in most of the cases, so no need to specify them in the `up` command. If you couldn't find them running then you need specify them as follow: `docker-compose up -d nginx php-fpm mysql workspace`. @@ -306,7 +355,7 @@ Open your `.env` file and set the `DB_HOST` to `mysql`: DB_HOST=mysql ``` -*If you are using Laravel and you don't have it installed yet, see [How to Install Laravel in a Docker Container](#Install-Laravel).* +*If you want to use Laravel and you don't have it installed yet, see [How to Install Laravel in a Docker Container](#Install-Laravel).*