Merge branch 'support-mongo'
* support-mongo: add Mongo Support to the Readme added php-mongodb extension simple reformatting set the original volume path get mongo volum from the data container added mongodb driver for php5.5 5.6 added mongodb image + PHP7 driver Fix Conflicts in: docker-compose.yml php-fpm/Dockerfile-55 php-fpm/Dockerfile-56 php-fpm/Dockerfile-70 php-fpm/laravel.ini
This commit is contained in:
commit
f3eb6a5fc4
68
README.md
68
README.md
|
@ -40,6 +40,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant.
|
||||||
- [Install Laravel from a Docker Container](#Install-Laravel)
|
- [Install Laravel from a Docker Container](#Install-Laravel)
|
||||||
- [Run Artisan Commands](#Run-Artisan-Commands)
|
- [Run Artisan Commands](#Run-Artisan-Commands)
|
||||||
- [Use Redis](#Use-Redis)
|
- [Use Redis](#Use-Redis)
|
||||||
|
- [Use Mongo](#Use-Mongo)
|
||||||
- [PHP](#PHP)
|
- [PHP](#PHP)
|
||||||
- [Install PHP Extensions](#Install-PHP-Extensions)
|
- [Install PHP Extensions](#Install-PHP-Extensions)
|
||||||
- [Change the PHP-FPM Version](#Change-the-PHP-FPM-Version)
|
- [Change the PHP-FPM Version](#Change-the-PHP-FPM-Version)
|
||||||
|
@ -92,6 +93,7 @@ docker-compose up nginx mysql redis
|
||||||
- PostgreSQL
|
- PostgreSQL
|
||||||
- MariaDB
|
- MariaDB
|
||||||
- Neo4j
|
- Neo4j
|
||||||
|
- MongoDB
|
||||||
- Redis
|
- Redis
|
||||||
- Memcached
|
- Memcached
|
||||||
- Beanstalkd
|
- Beanstalkd
|
||||||
|
@ -208,7 +210,7 @@ docker-compose up -d nginx mysql
|
||||||
*Note: the PHP-FPM, Workspace, Application and Data Containers will automatically run.*
|
*Note: the PHP-FPM, Workspace, Application and Data Containers will automatically run.*
|
||||||
|
|
||||||
|
|
||||||
Supported Containers: `nginx`, `mysql`, `redis`, `postgres`, `mariadb`, `neo4j`, `memcached`, `beanstalkd`, `beanstalkd-console`, `workspace`, `data`, `php-fpm`, `application`.
|
Supported Containers: `nginx`, `mysql`, `redis`, `postgres`, `mariadb`, `neo4j`, `mongo`, `memcached`, `beanstalkd`, `beanstalkd-console`, `workspace`, `data`, `php-fpm`, `application`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -512,9 +514,6 @@ Composer update
|
||||||
```bash
|
```bash
|
||||||
phpunit
|
phpunit
|
||||||
```
|
```
|
||||||
```bash
|
|
||||||
laravel new blog
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -527,7 +526,11 @@ laravel new blog
|
||||||
<a name="Use-Redis"></a>
|
<a name="Use-Redis"></a>
|
||||||
### Use Redis
|
### Use Redis
|
||||||
|
|
||||||
1 - First make sure you run the Redis Container with the `docker-compose` command.
|
1 - First make sure you run the Redis Container (`redis`) with the `docker-compose up` command.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose up -d redis
|
||||||
|
```
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
@ -555,7 +558,7 @@ CACHE_DRIVER=redis
|
||||||
SESSION_DRIVER=redis
|
SESSION_DRIVER=redis
|
||||||
```
|
```
|
||||||
|
|
||||||
4 - Finally make sure you have the `predis/predis` package `(~1.0)` installed via Composer first.
|
4 - Finally make sure you have the `predis/predis` package `(~1.0)` installed via Composer:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
composer require predis/predis:^1.0
|
composer require predis/predis:^1.0
|
||||||
|
@ -571,6 +574,59 @@ composer require predis/predis:^1.0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<a name="Use-Mongo"></a>
|
||||||
|
### Use Mongo
|
||||||
|
|
||||||
|
1 - First make sure you run the MongoDB Container (`mongo`) with the `docker-compose up` command.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose up -d mongo
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
2 - Add the MongoDB configurations to the `config/database.php` config file:
|
||||||
|
|
||||||
|
```php
|
||||||
|
'connections' => [
|
||||||
|
|
||||||
|
'mongodb' => [
|
||||||
|
'driver' => 'mongodb',
|
||||||
|
'host' => env('DB_HOST', 'localhost'),
|
||||||
|
'port' => env('DB_PORT', 27017),
|
||||||
|
'database' => env('DB_DATABASE', 'database'),
|
||||||
|
'username' => '',
|
||||||
|
'password' => '',
|
||||||
|
'options' => [
|
||||||
|
'database' => '',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
],
|
||||||
|
```
|
||||||
|
|
||||||
|
3 - Open your Laravel's `.env` file and update the following variables:
|
||||||
|
|
||||||
|
- set the `DB_HOST` to your `Docker-IP`.
|
||||||
|
- set the `DB_PORT` to `27017`.
|
||||||
|
- set the `DB_DATABASE` to `database`.
|
||||||
|
|
||||||
|
|
||||||
|
4 - Finally make sure you have the `jenssegers/mongodb` package installed via Composer and its Service Provider is added.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer require jenssegers/mongodb
|
||||||
|
```
|
||||||
|
More details about this [here](https://github.com/jenssegers/laravel-mongodb#installation).
|
||||||
|
|
||||||
|
5 - Test it:
|
||||||
|
|
||||||
|
- First let your Models extend from the Mongo Eloquent Model. Check the [documentation](https://github.com/jenssegers/laravel-mongodb#eloquent).
|
||||||
|
- Enter the Workspace Continer `docker exec -it laradock_workspace_1 bash`.
|
||||||
|
- Migrate the Database `php artisan migrate`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,9 @@ services:
|
||||||
- /var/lib/postgres:/var/lib/postgres
|
- /var/lib/postgres:/var/lib/postgres
|
||||||
- /var/lib/mariadb:/var/lib/mariadb
|
- /var/lib/mariadb:/var/lib/mariadb
|
||||||
- /var/lib/memcached:/var/lib/memcached
|
- /var/lib/memcached:/var/lib/memcached
|
||||||
- /var/lib/neo4j:/var/lib/neo4j/data
|
|
||||||
- /var/lib/redis:/data
|
- /var/lib/redis:/data
|
||||||
|
- /var/lib/neo4j:/var/lib/neo4j/data
|
||||||
|
- /var/lib/mongo:/data/db
|
||||||
|
|
||||||
### Nginx Server Container ##################################
|
### Nginx Server Container ##################################
|
||||||
|
|
||||||
|
@ -101,6 +102,15 @@ services:
|
||||||
volumes_from:
|
volumes_from:
|
||||||
- data
|
- data
|
||||||
|
|
||||||
|
### MongoDB Container #######################################
|
||||||
|
|
||||||
|
mongo:
|
||||||
|
build: ./mongo
|
||||||
|
ports:
|
||||||
|
- "27017:27017"
|
||||||
|
volumes_from:
|
||||||
|
- data
|
||||||
|
|
||||||
### Redis Container #########################################
|
### Redis Container #########################################
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
FROM mongo:latest
|
||||||
|
|
||||||
|
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
|
||||||
|
|
||||||
|
#COPY mongo.conf /usr/local/etc/mongo/mongo.conf
|
||||||
|
|
||||||
|
VOLUME /data/db /data/configdb
|
||||||
|
|
||||||
|
CMD ["mongod"]
|
||||||
|
|
||||||
|
EXPOSE 27017
|
||||||
|
|
|
@ -25,6 +25,9 @@ RUN pecl install memcached \
|
||||||
RUN pecl install xdebug \
|
RUN pecl install xdebug \
|
||||||
&& docker-php-ext-enable xdebug
|
&& docker-php-ext-enable xdebug
|
||||||
|
|
||||||
|
# Install mongodb driver
|
||||||
|
RUN pecl install mongodb
|
||||||
|
|
||||||
RUN usermod -u 1000 www-data
|
RUN usermod -u 1000 www-data
|
||||||
|
|
||||||
WORKDIR /var/www/laravel
|
WORKDIR /var/www/laravel
|
||||||
|
|
|
@ -25,6 +25,9 @@ RUN pecl install memcached \
|
||||||
RUN pecl install xdebug \
|
RUN pecl install xdebug \
|
||||||
&& docker-php-ext-enable xdebug
|
&& docker-php-ext-enable xdebug
|
||||||
|
|
||||||
|
# Install mongodb driver
|
||||||
|
RUN pecl install mongodb
|
||||||
|
|
||||||
RUN usermod -u 1000 www-data
|
RUN usermod -u 1000 www-data
|
||||||
|
|
||||||
WORKDIR /var/www/laravel
|
WORKDIR /var/www/laravel
|
||||||
|
|
|
@ -29,6 +29,9 @@ RUN curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached-dev/php-m
|
||||||
RUN pecl install xdebug \
|
RUN pecl install xdebug \
|
||||||
&& docker-php-ext-enable xdebug
|
&& docker-php-ext-enable xdebug
|
||||||
|
|
||||||
|
# Install mongodb driver
|
||||||
|
RUN pecl install mongodb
|
||||||
|
|
||||||
RUN usermod -u 1000 www-data
|
RUN usermod -u 1000 www-data
|
||||||
|
|
||||||
WORKDIR /var/www/laravel
|
WORKDIR /var/www/laravel
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
date.timezone=UTC
|
date.timezone=UTC
|
||||||
display_errors=Off
|
display_errors=Off
|
||||||
log_errors=On
|
log_errors=On
|
||||||
|
extension=mongodb.so
|
||||||
|
|
|
@ -34,6 +34,12 @@ RUN apt-get update && apt-get install -y --force-yes \
|
||||||
php7.0-sqlite3 \
|
php7.0-sqlite3 \
|
||||||
php7.0-zip \
|
php7.0-zip \
|
||||||
php7.0-memcached \
|
php7.0-memcached \
|
||||||
|
php-dev \
|
||||||
|
libcurl4-openssl-dev \
|
||||||
|
libedit-dev \
|
||||||
|
libssl-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
xz-utils \
|
||||||
sqlite3 \
|
sqlite3 \
|
||||||
libsqlite3-dev \
|
libsqlite3-dev \
|
||||||
git \
|
git \
|
||||||
|
@ -66,6 +72,10 @@ RUN curl -s http://getcomposer.org/installer | php \
|
||||||
&& mv composer.phar /usr/local/bin/ \
|
&& mv composer.phar /usr/local/bin/ \
|
||||||
&& echo "alias composer='/usr/local/bin/composer.phar'" >> ~/.bashrc
|
&& echo "alias composer='/usr/local/bin/composer.phar'" >> ~/.bashrc
|
||||||
|
|
||||||
|
# Install mongodb extension
|
||||||
|
RUN pecl install mongodb
|
||||||
|
RUN echo "extension=mongodb.so" >> /etc/php/7.0/cli/php.ini
|
||||||
|
|
||||||
# Source the bash
|
# Source the bash
|
||||||
RUN . ~/.bashrc
|
RUN . ~/.bashrc
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue