Skip to content

Commit

Permalink
Merge pull request laradock#399 from LaraDock/multiple-projects
Browse files Browse the repository at this point in the history
Multiple projects
  • Loading branch information
Mahmoudz authored Nov 1, 2016
2 parents 6ee790c + 66723c0 commit 3070eac
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 110 deletions.
87 changes: 76 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -206,17 +207,22 @@ What's better than a **Demo Video**:
<a name="Installation"></a>
## 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
Expand All @@ -225,9 +231,10 @@ Note: In this case the folder structure will be like this (recommended):
- 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
git clone https://github.com/LaraDock/laradock.git
Expand All @@ -237,11 +244,54 @@ Note: In this case the folder structure will be like this:
```
- projects
- laradock
- project1
- project2
- myProject
```

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
```

**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".
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>
## Usage
Expand All @@ -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`.
Expand Down Expand Up @@ -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).*



Expand Down Expand Up @@ -1096,6 +1146,21 @@ ports:
- "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>
### Use custom Domain (instead of the Docker IP)

Expand Down
16 changes: 9 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions nginx/sites/laravel.conf → nginx/sites/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 / {
Expand Down
57 changes: 0 additions & 57 deletions nginx/sites/framework-examples/drupal_8.conf

This file was deleted.

4 changes: 2 additions & 2 deletions nginx/sites/site_a.conf → nginx/sites/sample.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -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 / {
Expand Down
28 changes: 0 additions & 28 deletions nginx/sites/site_b.conf

This file was deleted.

2 changes: 1 addition & 1 deletion php-fpm/Dockerfile-56
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion php-fpm/Dockerfile-70
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion workspace/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3070eac

Please sign in to comment.