diff --git a/README.md b/README.md index cc84aa8e..8a1ea1e4 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) @@ -206,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 @@ -225,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 @@ -237,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 @@ -267,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`. @@ -305,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).* @@ -1096,6 +1146,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) 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 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/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; - } -} diff --git a/nginx/sites/site_a.conf b/nginx/sites/sample.conf.example similarity index 88% rename from nginx/sites/site_a.conf rename to nginx/sites/sample.conf.example index 6bd32690..e6520e59 100644 --- a/nginx/sites/site_a.conf +++ b/nginx/sites/sample.conf.example @@ -3,8 +3,8 @@ server { listen 80; listen [::]:80; - server_name site_a; - root /var/www/site_a/public; + server_name sample.dev; + root /var/www/sample/public; index index.php index.html index.htm; location / { 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; - } -} - - - 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