Skip to content

Commit 5ebb061

Browse files
authored
Merge pull request laradock#3 from LaraDock/master
Merge
2 parents ad49981 + e5e04e4 commit 5ebb061

10 files changed

Lines changed: 245 additions & 91 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/logs
1+
/logs
2+
.env

README.md

Lines changed: 104 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant.
4040
- [Install Laravel from a Docker Container](#Install-Laravel)
4141
- [Run Artisan Commands](#Run-Artisan-Commands)
4242
- [Use Redis](#Use-Redis)
43+
- [Use Mongo](#Use-Mongo)
4344
- [PHP](#PHP)
4445
- [Install PHP Extensions](#Install-PHP-Extensions)
4546
- [Change the PHP-FPM Version](#Change-the-PHP-FPM-Version)
@@ -48,6 +49,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant.
4849
- [Run a Docker Virtual Host](#Run-Docker-Virtual-Host)
4950
- [Find your Docker IP Address](#Find-Docker-IP-Address)
5051
- [Use custom Domain](#Use-custom-Domain)
52+
- [Debugging](#debugging)
5153
- [Help & Questions](#Help)
5254

5355

@@ -91,6 +93,7 @@ docker-compose up nginx mysql redis
9193
- PostgreSQL
9294
- MariaDB
9395
- Neo4j
96+
- MongoDB
9497
- Redis
9598
- Memcached
9699
- Beanstalkd
@@ -188,34 +191,37 @@ git clone https://github.com/LaraDock/laradock.git
188191

189192

190193
1 - For **Windows & MAC** users only: If you are not using the native Docker-Engine `Beta`, make sure you have a running Docker Virtual Host on your machine.
191-
(**Linux** users don't need a Virtual Host, so skip this step).
192-
193194
[How to run a Docker Virtual Host?](#Run-Docker-Virtual-Host)
195+
(**Linux** users don't need a Virtual Host, so skip this step).
194196

195197

196198
<br>
197-
2 - Run the Containers, (you can select the containers that you wish to run)
198-
<br>
199-
*Make sure you are in the `laradock` folder before running the `docker-compose` command.*
199+
2 - Run some Containers: *(Make sure you are in the `laradock` folder before running the `docker-compose` commands).*
200+
201+
200202

201203
**Example:** Running NGINX and MySQL:
202204

203205
```bash
204206
docker-compose up -d nginx mysql
205207
```
206208

207-
*Note: the PHP-FPM, Workspace, Application and Data Containers will automatically run.*
209+
You can select your own combination of container form this list:
210+
211+
`nginx`, `mysql`, `redis`, `postgres`, `mariadb`, `neo4j`, `mongo`, `memcached`, `beanstalkd`, `beanstalkd-console`, `workspace`, `data`, `php-fpm`, `application`.
212+
213+
214+
**Note**: `workspace`, `data`, `php-fpm` and `application` will run automatically in most of the cases.
208215

209216

210-
Supported Containers: `nginx`, `mysql`, `redis`, `postgres`, `mariadb`, `neo4j`, `memcached`, `beanstalkd`, `beanstalkd-console`, `workspace`, `data`, `php-fpm`, `application`.
211217

212218

213219

214220
<br>
215221
3 - Enter the Workspace container, to execute commands like (Artisan, Composer, PHPUnit, Gulp, ...).
216222

217223
```bash
218-
docker exec -it {Workspace-Container-Name} bash
224+
docker-compose run workspace bash
219225
```
220226
Replace `{Workspace-Container-Name}` with your Workspace container name.
221227
<br>
@@ -242,15 +248,11 @@ DB_HOST=xxx.xxx.xxx.xxx
242248
5 - Open your browser and visit your `{Docker-IP}` address (`http://xxx.xxx.xxx.xxx`).
243249

244250

245-
<br>
246-
**Debugging**: in case you faced an error here, run this command from the Laravel root directory:
247-
248-
```bash
249-
sudo chmod -R 777 storage bootstrap/cache
250-
```
251251

252252
<br>
253-
If you have any problem, or need a special support. Feel free to contact me, more details in the [Help & Questions](#Help) secion.
253+
**Debugging**: if you are facing any problem here check the [Debugging](#debugging) section.
254+
255+
If you need a special support. Contact me, more details in the [Help & Questions](#Help) section.
254256

255257

256258
<br>
@@ -321,7 +323,7 @@ docker-compose down
321323
2 - enter any container using:
322324

323325
```bash
324-
docker exec -it {container-name} bash
326+
docker-compose run {container-name} bash
325327
```
326328
3 - to exit a container, type `exit`.
327329

@@ -492,19 +494,13 @@ You can run artisan commands and many other Terminal commands from the Workspace
492494
docker-compose up -d workspace // ..and all your other containers
493495
```
494496

495-
2 - Find the Workspace container name:
496-
497-
```bash
498-
docker-compose ps
499-
```
500-
501-
3 - Enter the Workspace container:
497+
2 - Enter the Workspace container:
502498

503499
```bash
504-
docker exec -it {workspace-container-name} bash
500+
docker-compose run workspace /bin/bash
505501
```
506502

507-
4 - Run anything you want :)
503+
3 - Run anything you want :)
508504

509505
```bash
510506
php artisan
@@ -515,22 +511,16 @@ Composer update
515511
```bash
516512
phpunit
517513
```
518-
```bash
519-
laravel new blog
520-
```
521-
522-
523-
524-
525-
526-
527-
528514

529515
<br>
530516
<a name="Use-Redis"></a>
531517
### Use Redis
532518

533-
1 - First make sure you run the Redis Container with the `docker-compose` command.
519+
1 - First make sure you run the Redis Container (`redis`) with the `docker-compose up` command.
520+
521+
```bash
522+
docker-compose up -d redis
523+
```
534524

535525
2 - Open your Laravel's `.env` file and set the `REDIS_HOST` to your `Docker-IP` instead of the default `127.0.0.1` IP.
536526

@@ -558,7 +548,7 @@ CACHE_DRIVER=redis
558548
SESSION_DRIVER=redis
559549
```
560550

561-
4 - Finally make sure you have the `predis/predis` package `(~1.0)` installed via Composer first.
551+
4 - Finally make sure you have the `predis/predis` package `(~1.0)` installed via Composer:
562552

563553
```bash
564554
composer require predis/predis:^1.0
@@ -574,6 +564,59 @@ composer require predis/predis:^1.0
574564

575565

576566

567+
<br>
568+
<a name="Use-Mongo"></a>
569+
### Use Mongo
570+
571+
1 - First make sure you run the MongoDB Container (`mongo`) with the `docker-compose up` command.
572+
573+
```bash
574+
docker-compose up -d mongo
575+
```
576+
577+
578+
2 - Add the MongoDB configurations to the `config/database.php` config file:
579+
580+
```php
581+
'connections' => [
582+
583+
'mongodb' => [
584+
'driver' => 'mongodb',
585+
'host' => env('DB_HOST', 'localhost'),
586+
'port' => env('DB_PORT', 27017),
587+
'database' => env('DB_DATABASE', 'database'),
588+
'username' => '',
589+
'password' => '',
590+
'options' => [
591+
'database' => '',
592+
]
593+
],
594+
595+
// ...
596+
597+
],
598+
```
599+
600+
3 - Open your Laravel's `.env` file and update the following variables:
601+
602+
- set the `DB_HOST` to your `Docker-IP`.
603+
- set the `DB_PORT` to `27017`.
604+
- set the `DB_DATABASE` to `database`.
605+
606+
607+
4 - Finally make sure you have the `jenssegers/mongodb` package installed via Composer and its Service Provider is added.
608+
609+
```bash
610+
composer require jenssegers/mongodb
611+
```
612+
More details about this [here](https://github.com/jenssegers/laravel-mongodb#installation).
613+
614+
5 - Test it:
615+
616+
- First let your Models extend from the Mongo Eloquent Model. Check the [documentation](https://github.com/jenssegers/laravel-mongodb#eloquent).
617+
- Enter the Workspace Continer `docker-compose run workspace bash`.
618+
- Migrate the Database `php artisan migrate`.
619+
577620

578621

579622

@@ -773,43 +816,52 @@ server_name laravel.dev;
773816
```
774817

775818

819+
<br>
820+
<a name="debugging"></a>
821+
### Debugging
776822

823+
*Here's a list of the common problems you might face, and the possible solutions.*
777824

825+
#### + I see a blank (white) page instead of the Laravel 'Welcome' page!
778826

827+
run this command from the Laravel root directory:
828+
829+
```bash
830+
sudo chmod -R 777 storage bootstrap/cache
831+
```
832+
833+
#### + I see "Welcome to nginx" instead of the Laravel App!
834+
835+
use `http://127.0.0.1` instead of `http://localhost` in your browser.
779836

780837

781838

782839

783840

784-
<br>
785-
## Contributing
786841

787-
This little project was built by one man who has a full time job and many responsibilities, so if you like this project and you find that it needs a bug fix or support for new software or upgrade any container, or anything else.. Do not hesitate to contribute, you are more than welcome :)
788842

789-
## Support
790843

791-
To suggest a features or report a bug, open a new [Issue](https://github.com/laradock/laradock/issues).
792844

845+
<br>
846+
## Contributing
847+
848+
This little project was built by one man who has a full time job and many responsibilities, so if you like this project and you find that it needs a bug fix or support for new software or upgrade any container, or anything else.. Do not hesitate to contribute, you are more than welcome :)
793849

794850

795851
<a name="Help"></a>
796852
## Help & Questions
797853

798-
If you need help with anything related to this project, shedule a live call with me on [Codementor](https://www.codementor.io/mahmoudz), I'd love to help.
854+
If you need any help with Docker and Laravel, you can schedule a live call with the creator of this project at [Codementor.io](https://www.codementor.io/mahmoudz), He would love to help.
799855

800-
If you have a short question, send me a direct message on LaraChat, my username is `mahmoud_zalt`. Or send me an email on `mahmoud@zalt.me`.
856+
For general questions you can open [Issues](https://github.com/laradock/laradock/issues) here on Github (We will label them as questions).
801857

858+
Additionally, you can contact Mahmoud Zalt (the creator of this project) via a direct message on LaraChat, (his username is `mahmoud_zalt`). Or send him an email (`mahmoud@zalt.me`).
802859

803-
## Credits
804860

805-
[![Mahmoud Zalt](https://img.shields.io/badge/Author-Mahmoud%20Zalt-orange.svg)](http://www.zalt.me)
806-
807-
Twitter: [@Mahmoud_Zalt](https://twitter.com/Mahmoud_Zalt)
808-
<br>
809-
Website: [http://zalt.me](http://zalt.me)
810-
<br>
811-
Email: `mahmoud@zalt.me`
861+
## Credits
812862

863+
- [Mahmoud Zalt](https://github.com/Mahmoudz) (Twitter [@Mahmoud_Zalt](https://twitter.com/Mahmoud_Zalt))
864+
- [Awesome list of contributors](https://github.com/LaraDock/laradock/graphs/contributors)
813865

814866
## License
815867

docker-compose.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ services:
2727
data:
2828
build: ./data
2929
volumes:
30-
- /var/lib/mysql
31-
- /var/lib/postgres
32-
- /var/lib/mariadb
33-
- /var/lib/redis
34-
- /var/lib/memcached
35-
- /var/lib/neo4j/data
30+
- /var/lib/mysql:/var/lib/mysql
31+
- /var/lib/postgres:/var/lib/postgres
32+
- /var/lib/mariadb:/var/lib/mariadb
33+
- /var/lib/memcached:/var/lib/memcached
34+
- /var/lib/redis:/data
35+
- /var/lib/neo4j:/var/lib/neo4j/data
36+
- /var/lib/mongo:/data/db
3637

3738
### Nginx Server Container ##################################
3839

@@ -77,7 +78,7 @@ services:
7778

7879
### MariaDB Container #######################################
7980

80-
mariadb:
81+
mariadb:
8182
build: ./mariadb
8283
volumes_from:
8384
- data
@@ -101,6 +102,15 @@ services:
101102
volumes_from:
102103
- data
103104

105+
### MongoDB Container #######################################
106+
107+
mongo:
108+
build: ./mongo
109+
ports:
110+
- "27017:27017"
111+
volumes_from:
112+
- data
113+
104114
### Redis Container #########################################
105115

106116
redis:
@@ -143,7 +153,10 @@ services:
143153
### Workspace Utilities Container ###########################
144154

145155
workspace:
146-
build: ./workspace
156+
build:
157+
context: ./workspace
158+
args:
159+
INSTALL_PRESTISSIMO: ${INSTALL_PRESTISSIMO}
147160
volumes_from:
148161
- application
149162
tty: true

mongo/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM mongo:latest
2+
3+
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
4+
5+
#COPY mongo.conf /usr/local/etc/mongo/mongo.conf
6+
7+
VOLUME /data/db /data/configdb
8+
9+
CMD ["mongod"]
10+
11+
EXPOSE 27017
12+

php-fpm/Dockerfile-55

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,34 @@ ADD ./laravel.pool.conf /usr/local/etc/php-fpm.d/
88
RUN apt-get update && apt-get install -y \
99
libpq-dev \
1010
libmemcached-dev \
11-
curl
11+
curl \
12+
libpng12-dev \
13+
libfreetype6-dev \
14+
--no-install-recommends \
15+
&& rm -r /var/lib/apt/lists/*
16+
17+
# configure gd library
18+
RUN docker-php-ext-configure gd \
19+
--enable-gd-native-ttf \
20+
--with-freetype-dir=/usr/include/freetype2
1221

1322
# Install extensions using the helper script provided by the base image
1423
RUN docker-php-ext-install \
1524
pdo_mysql \
16-
pdo_pgsql
25+
pdo_pgsql \
26+
gd
1727

18-
#Install memcached
28+
# Install memcached
1929
RUN pecl install memcached \
2030
&& docker-php-ext-enable memcached
2131

32+
# Install xdebug
33+
RUN pecl install xdebug \
34+
&& docker-php-ext-enable xdebug
35+
36+
# Install mongodb driver
37+
RUN pecl install mongodb
38+
2239
RUN usermod -u 1000 www-data
2340

2441
WORKDIR /var/www/laravel

0 commit comments

Comments
 (0)