Skip to content

Commit 3070eac

Browse files
authored
Merge pull request laradock#399 from LaraDock/multiple-projects
Multiple projects
2 parents 6ee790c + 66723c0 commit 3070eac

9 files changed

Lines changed: 92 additions & 110 deletions

File tree

README.md

Lines changed: 76 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Laradock is configured to run Laravel Apps by default, and it can be modifyed to
6060
- [Cron jobs](#CronJobs)
6161
- [Access workspace via ssh](#Workspace-ssh)
6262
- [MySQL access from host](#MySQL-access-from-host)
63+
- [MySQL root access](#MySQL-root-access)
6364
- [Use custom Domain](#Use-custom-Domain)
6465
- [Enable Global Composer Build Install](#Enable-Global-Composer-Build-Install)
6566
- [Install Prestissimo](#Install-Prestissimo)
@@ -206,17 +207,22 @@ What's better than a **Demo Video**:
206207
<a name="Installation"></a>
207208
## Installation
208209

210+
Choose the setup the best suits your needs.
209211

210-
Clone the `LaraDock` repository:
212+
#### A) Setup for Single Project:
213+
*(In case you want a Docker environment for each project)*
211214

212-
**A)** If you already have a Laravel project, clone this repository on your `Laravel` root directory:
215+
##### A.1) Setup environment in existing Project:
216+
*(In case you already have a project, and you want to setup an environemnt to run it)*
217+
218+
1 - Clone this repository on your project root directory:
213219

214220
```bash
215221
git submodule add https://github.com/LaraDock/laradock.git
216222
```
217-
>If you are not already using Git for your Laravel project, you can use `git clone` instead of `git submodule`.
223+
>If you are not already using Git for your PHP project, you can use `git clone` instead of `git submodule`.
218224
219-
Note: In this case the folder structure will be like this (recommended):
225+
Note: In this case the folder structure will be like this:
220226

221227
```
222228
- project1
@@ -225,9 +231,10 @@ Note: In this case the folder structure will be like this (recommended):
225231
- laradock
226232
```
227233

228-
<br>
234+
##### A.2) Setup environment first then create project:
235+
*(In case you don't have a project, and you want to create your project inside the Docker environment)*
229236

230-
**B)** If you don't have a Laravel project, and you want to install Laravel from Docker, clone this repo anywhere on your machine:
237+
1 - Clone this repository anywhere on your machine:
231238

232239
```bash
233240
git clone https://github.com/LaraDock/laradock.git
@@ -237,11 +244,54 @@ Note: In this case the folder structure will be like this:
237244
```
238245
- projects
239246
- laradock
240-
- project1
241-
- project2
247+
- myProject
248+
```
249+
250+
2 - Edit the `docker-compose.yml` file to map to your project directory once you have it (example: `- ../myProject:/var/www`).
251+
252+
3 - Stop and re-run your docker-compose command for the changes to take place.
253+
254+
```
255+
docker-compose stop && docker-compose up -d XXXX YYYY ZZZZ ....
256+
```
257+
258+
259+
#### B) Setup for Multiple Projects:
260+
261+
1 - Clone this repository anywhere on your machine:
262+
263+
```bash
264+
git clone https://github.com/LaraDock/laradock.git
265+
```
266+
267+
2 - Edit the `docker-compose.yml` file to map to your projects directories:
268+
269+
```
270+
volumes_source:
271+
image: tianon/true
272+
volumes:
273+
- ../project1/:/var/www/project1
274+
- ../project2/:/var/www/project2
242275
```
243276

244-
**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".
277+
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.
278+
279+
280+
4 - Go to `nginx/sites` and copy `sample.conf.example` to `project1.conf` then to `project2.conf`
281+
282+
5 - Open the `project1.conf` file and edit the `server_name` and the `root` as follow:
283+
284+
```
285+
server_name project1.dev;
286+
root /var/www/project1/public;
287+
```
288+
Do the same for each project `project2.conf`, `project3.conf`,...
289+
290+
6 - Create your project Databases **To Be Continue..**
291+
292+
293+
294+
245295

246296
<a name="Usage"></a>
247297
## Usage
@@ -267,7 +317,7 @@ If you are using **Docker Toolbox** (VM), do one of the following:
267317
**Example:** Running NGINX and MySQL:
268318

269319
```bash
270-
docker-compose up -d nginx mysql
320+
docker-compose up -d nginx mysql
271321
```
272322

273323
**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`:
305355
DB_HOST=mysql
306356
```
307357

308-
*If you are using Laravel and you don't have it installed yet, see [How to Install Laravel in a Docker Container](#Install-Laravel).*
358+
*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).*
309359

310360

311361

@@ -1096,6 +1146,21 @@ ports:
10961146
- "3306:3306"
10971147
```
10981148

1149+
<a name="MySQL-root-access"></a>
1150+
### MySQL root access
1151+
1152+
The default username and password for the root mysql user are `root` and `root `.
1153+
1154+
1 - Enter the mysql contaier: `docker-compose exec mysql bash`.
1155+
1156+
2 - Enter mysql: `mysql -uroot -proot` for non root access use `mysql -uhomestead -psecret`.
1157+
1158+
3 - See all users: `SELECT User FROM mysql.user;`
1159+
1160+
4 - Run any commands `show databases`, `show tables`, `select * from.....`.
1161+
1162+
1163+
10991164
<a name="Use-custom-Domain"></a>
11001165
### Use custom Domain (instead of the Docker IP)
11011166

docker-compose.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ version: '2'
22

33
services:
44

5+
### Applications Code Container ######################
6+
7+
volumes_source:
8+
image: tianon/true
9+
volumes:
10+
- ../:/var/www
11+
# - ../sample/:/var/www/sample
12+
513
### Workspace Utilities Container ###########################
614

715
workspace:
@@ -288,19 +296,13 @@ services:
288296
links:
289297
- php-fpm
290298

291-
### Laravel Application Code Container ######################
292-
293-
volumes_source:
294-
image: tianon/true
295-
volumes:
296-
- ../:/var/www/laravel
297-
298299
### Databases Data Container ################################
299300

300301
volumes_data:
301302
image: tianon/true
302303
volumes:
303304
- ./data/mysql:/var/lib/mysql
305+
- ./databases:/docker-entrypoint-initdb.d
304306
- ./data/postgres:/var/lib/postgresql/data
305307
- ./data/memcached:/var/lib/memcached
306308
- ./data/redis:/data
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ server {
33
listen 80 default_server;
44
listen [::]:80 default_server ipv6only=on;
55

6-
server_name laravel;
7-
root /var/www/laravel/public;
6+
server_name laradock;
7+
root /var/www/public;
88
index index.php index.html index.htm;
99

1010
location / {

nginx/sites/framework-examples/drupal_8.conf

Lines changed: 0 additions & 57 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ server {
33
listen 80;
44
listen [::]:80;
55

6-
server_name site_a;
7-
root /var/www/site_a/public;
6+
server_name sample.dev;
7+
root /var/www/sample/public;
88
index index.php index.html index.htm;
99

1010
location / {

nginx/sites/site_b.conf

Lines changed: 0 additions & 28 deletions
This file was deleted.

php-fpm/Dockerfile-56

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ RUN rm -r /var/lib/apt/lists/*
142142

143143
RUN usermod -u 1000 www-data
144144

145-
WORKDIR /var/www/laravel
145+
WORKDIR /var/www
146146

147147
CMD ["php-fpm"]
148148

php-fpm/Dockerfile-70

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ RUN rm -r /var/lib/apt/lists/*
153153

154154
RUN usermod -u 1000 www-data
155155

156-
WORKDIR /var/www/laravel
156+
WORKDIR /var/www
157157

158158
CMD ["php-fpm"]
159159

workspace/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,4 +246,4 @@ RUN apt-get clean && \
246246
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
247247

248248
# Set default work directory
249-
WORKDIR /var/www/laravel
249+
WORKDIR /var/www

0 commit comments

Comments
 (0)