Merge pull request #399 from LaraDock/multiple-projects

Multiple projects
This commit is contained in:
Mahmoud Zalt 2016-10-31 20:32:44 -04:00 committed by GitHub
commit 3070eac7b7
9 changed files with 92 additions and 110 deletions

View File

@ -60,6 +60,7 @@ Laradock is configured to run Laravel Apps by default, and it can be modifyed to
- [Cron jobs](#CronJobs) - [Cron jobs](#CronJobs)
- [Access workspace via ssh](#Workspace-ssh) - [Access workspace via ssh](#Workspace-ssh)
- [MySQL access from host](#MySQL-access-from-host) - [MySQL access from host](#MySQL-access-from-host)
- [MySQL root access](#MySQL-root-access)
- [Use custom Domain](#Use-custom-Domain) - [Use custom Domain](#Use-custom-Domain)
- [Enable Global Composer Build Install](#Enable-Global-Composer-Build-Install) - [Enable Global Composer Build Install](#Enable-Global-Composer-Build-Install)
- [Install Prestissimo](#Install-Prestissimo) - [Install Prestissimo](#Install-Prestissimo)
@ -206,17 +207,22 @@ What's better than a **Demo Video**:
<a name="Installation"></a> <a name="Installation"></a>
## Installation ## 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 ```bash
git submodule add https://github.com/LaraDock/laradock.git 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 - project1
@ -225,9 +231,10 @@ Note: In this case the folder structure will be like this (recommended):
- laradock - laradock
``` ```
<br> ##### 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 ```bash
git clone https://github.com/LaraDock/laradock.git git clone https://github.com/LaraDock/laradock.git
@ -237,11 +244,54 @@ Note: In this case the folder structure will be like this:
``` ```
- projects - projects
- laradock - laradock
- project1 - myProject
- project2
``` ```
**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..**
<a name="Usage"></a> <a name="Usage"></a>
## Usage ## Usage
@ -305,7 +355,7 @@ Open your `.env` file and set the `DB_HOST` to `mysql`:
DB_HOST=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" - "3306:3306"
``` ```
<a name="MySQL-root-access"></a>
### 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.....`.
<a name="Use-custom-Domain"></a> <a name="Use-custom-Domain"></a>
### Use custom Domain (instead of the Docker IP) ### Use custom Domain (instead of the Docker IP)

View File

@ -2,6 +2,14 @@ version: '2'
services: services:
### Applications Code Container ######################
volumes_source:
image: tianon/true
volumes:
- ../:/var/www
# - ../sample/:/var/www/sample
### Workspace Utilities Container ########################### ### Workspace Utilities Container ###########################
workspace: workspace:
@ -288,19 +296,13 @@ services:
links: links:
- php-fpm - php-fpm
### Laravel Application Code Container ######################
volumes_source:
image: tianon/true
volumes:
- ../:/var/www/laravel
### Databases Data Container ################################ ### Databases Data Container ################################
volumes_data: volumes_data:
image: tianon/true image: tianon/true
volumes: volumes:
- ./data/mysql:/var/lib/mysql - ./data/mysql:/var/lib/mysql
- ./databases:/docker-entrypoint-initdb.d
- ./data/postgres:/var/lib/postgresql/data - ./data/postgres:/var/lib/postgresql/data
- ./data/memcached:/var/lib/memcached - ./data/memcached:/var/lib/memcached
- ./data/redis:/data - ./data/redis:/data

View File

@ -3,8 +3,8 @@ server {
listen 80 default_server; listen 80 default_server;
listen [::]:80 default_server ipv6only=on; listen [::]:80 default_server ipv6only=on;
server_name laravel; server_name laradock;
root /var/www/laravel/public; root /var/www/public;
index index.php index.html index.htm; index index.php index.html index.htm;
location / { location / {

View File

@ -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&#39;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;
}
}

View File

@ -3,8 +3,8 @@ server {
listen 80; listen 80;
listen [::]:80; listen [::]:80;
server_name site_a; server_name sample.dev;
root /var/www/site_a/public; root /var/www/sample/public;
index index.php index.html index.htm; index index.php index.html index.htm;
location / { location / {

View File

@ -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;
}
}

View File

@ -142,7 +142,7 @@ RUN rm -r /var/lib/apt/lists/*
RUN usermod -u 1000 www-data RUN usermod -u 1000 www-data
WORKDIR /var/www/laravel WORKDIR /var/www
CMD ["php-fpm"] CMD ["php-fpm"]

View File

@ -153,7 +153,7 @@ RUN rm -r /var/lib/apt/lists/*
RUN usermod -u 1000 www-data RUN usermod -u 1000 www-data
WORKDIR /var/www/laravel WORKDIR /var/www
CMD ["php-fpm"] CMD ["php-fpm"]

View File

@ -246,4 +246,4 @@ RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Set default work directory # Set default work directory
WORKDIR /var/www/laravel WORKDIR /var/www