make Mongo, xDebug, Node, and prestissimo Installation Optional
on the Workspace and PHP-FPM Containers + general refactoring
This commit is contained in:
parent
419434020c
commit
e1dbb972f1
120
README.md
120
README.md
@ -48,11 +48,13 @@ It's like Laravel Homestead but for Docker instead of Vagrant.
|
||||
- [Install PHP Extensions](#Install-PHP-Extensions)
|
||||
- [Change the PHP-FPM Version](#Change-the-PHP-FPM-Version)
|
||||
- [Change the PHP-CLI Version](#Change-the-PHP-CLI-Version)
|
||||
- [Install xDebug](#Install-xDebug)
|
||||
- [Misc](#Misc)
|
||||
- [Run a Docker Virtual Host](#Run-Docker-Virtual-Host)
|
||||
- [Find your Docker IP Address](#Find-Docker-IP-Address)
|
||||
- [Use custom Domain](#Use-custom-Domain)
|
||||
- [Install Prestissimo](#Install-Prestissimo)
|
||||
- [Install Node + NVM](#Install-Node)
|
||||
- [Debugging](#debugging)
|
||||
- [Help & Questions](#Help)
|
||||
|
||||
@ -577,14 +579,47 @@ composer require predis/predis:^1.0
|
||||
<a name="Use-Mongo"></a>
|
||||
### Use Mongo
|
||||
|
||||
1 - First make sure you run the MongoDB Container (`mongo`) with the `docker-compose up` command.
|
||||
1 - First install `mongo` in the Workspace and the PHP-FPM Containers:
|
||||
<br>
|
||||
a) open the `docker-compose.yml` file
|
||||
<br>
|
||||
b) search for the `INSTALL_MONGO` argument under the Workspace Container
|
||||
<br>
|
||||
c) set it to `true`
|
||||
<br>
|
||||
d) search for the `INSTALL_MONGO` argument under the PHP-FPM Container
|
||||
<br>
|
||||
e) set it to `true`
|
||||
|
||||
It should be like this:
|
||||
|
||||
```yml
|
||||
workspace:
|
||||
build:
|
||||
context: ./workspace
|
||||
args:
|
||||
- INSTALL_MONGO=true
|
||||
...
|
||||
php-fpm:
|
||||
build:
|
||||
context: ./php-fpm
|
||||
args:
|
||||
- INSTALL_MONGO=true
|
||||
...
|
||||
```
|
||||
|
||||
2 - Re-build the containers docker-compose build workspace php-fpm
|
||||
|
||||
|
||||
|
||||
3 - 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:
|
||||
4 - Add the MongoDB configurations to the `config/database.php` config file:
|
||||
|
||||
```php
|
||||
'connections' => [
|
||||
@ -606,21 +641,21 @@ docker-compose up -d mongo
|
||||
],
|
||||
```
|
||||
|
||||
3 - Open your Laravel's `.env` file and update the following variables:
|
||||
5 - 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.
|
||||
6 - 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:
|
||||
7 - 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 Container `docker exec -it laradock_workspace_1 bash`.
|
||||
@ -732,10 +767,42 @@ Right now you have to manually edit the `Dockerfile` or create a new one like it
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<a name="Install-xDebug"></a>
|
||||
### Install xDebug
|
||||
|
||||
1 - First install `xDebug` in the Workspace and the PHP-FPM Containers:
|
||||
<br>
|
||||
a) open the `docker-compose.yml` file
|
||||
<br>
|
||||
b) search for the `INSTALL_XDEBUG` argument under the Workspace Container
|
||||
<br>
|
||||
c) set it to `true`
|
||||
<br>
|
||||
d) search for the `INSTALL_XDEBUG` argument under the PHP-FPM Container
|
||||
<br>
|
||||
e) set it to `true`
|
||||
|
||||
It should be like this:
|
||||
|
||||
```yml
|
||||
workspace:
|
||||
build:
|
||||
context: ./workspace
|
||||
args:
|
||||
- INSTALL_XDEBUG=true
|
||||
...
|
||||
php-fpm:
|
||||
build:
|
||||
context: ./php-fpm
|
||||
args:
|
||||
- INSTALL_XDEBUG=true
|
||||
...
|
||||
```
|
||||
|
||||
2 - Re-build the containers docker-compose build workspace php-fpm
|
||||
|
||||
3 - Use it
|
||||
|
||||
|
||||
|
||||
@ -843,7 +910,48 @@ server_name laravel.dev;
|
||||
<a name="Install-Prestissimo"></a>
|
||||
### Install Prestissimo
|
||||
|
||||
[Prestissimo](https://github.com/hirak/prestissimo) is a plugin for composer which enables parallel install functionality. You can enable Prestissimo by setting `INSTALL_PRESTISSIMO=true` in the `docker-compose.yml` file.
|
||||
[Prestissimo](https://github.com/hirak/prestissimo) is a plugin for composer which enables parallel install functionality.
|
||||
|
||||
To install Prestissimo in the Workspace container
|
||||
|
||||
1 - Open the `docker-compose.yml` file
|
||||
|
||||
2 - Search for the `INSTALL_PRESTISSIMO` argument under the Workspace Container and set it to `true`
|
||||
|
||||
It should be like this:
|
||||
|
||||
```yml
|
||||
workspace:
|
||||
build:
|
||||
context: ./workspace
|
||||
args:
|
||||
- INSTALL_PRESTISSIMO=true
|
||||
...
|
||||
```
|
||||
|
||||
3 - Re-build the container docker-compose build workspace
|
||||
|
||||
<a name="Install-Node"></a>
|
||||
### Install Node + NVM
|
||||
|
||||
To install NVM and NodeJS in the Workspace container
|
||||
|
||||
1 - Open the `docker-compose.yml` file
|
||||
|
||||
2 - Search for the `INSTALL_NODE` argument under the Workspace Container and set it to `true`
|
||||
|
||||
It should be like this:
|
||||
|
||||
```yml
|
||||
workspace:
|
||||
build:
|
||||
context: ./workspace
|
||||
args:
|
||||
- INSTALL_NODE=true
|
||||
...
|
||||
```
|
||||
|
||||
3 - Re-build the container docker-compose build workspace
|
||||
|
||||
<br>
|
||||
<a name="debugging"></a>
|
||||
|
@ -2,6 +2,36 @@ version: '2'
|
||||
|
||||
services:
|
||||
|
||||
### Workspace Utilities Container ###########################
|
||||
|
||||
workspace:
|
||||
build:
|
||||
context: ./workspace
|
||||
args:
|
||||
- INSTALL_MONGO=false
|
||||
- INSTALL_XDEBUG=false
|
||||
- INSTALL_NODE=false
|
||||
- INSTALL_PRESTISSIMO=false
|
||||
volumes_from:
|
||||
- volumes_source
|
||||
tty: true
|
||||
|
||||
### PHP-FPM Container #######################################
|
||||
|
||||
php-fpm:
|
||||
build:
|
||||
context: ./php-fpm
|
||||
args:
|
||||
- INSTALL_MONGO=false
|
||||
- INSTALL_XDEBUG=false
|
||||
dockerfile: Dockerfile-70
|
||||
volumes_from:
|
||||
- volumes_source
|
||||
expose:
|
||||
- "9000"
|
||||
links:
|
||||
- workspace
|
||||
|
||||
### Nginx Server Container ##################################
|
||||
|
||||
nginx:
|
||||
@ -19,19 +49,6 @@ services:
|
||||
links:
|
||||
- php-fpm
|
||||
|
||||
### PHP-FPM Container #######################################
|
||||
|
||||
php-fpm:
|
||||
build:
|
||||
context: ./php-fpm
|
||||
dockerfile: Dockerfile-70
|
||||
volumes_from:
|
||||
- volumes_source
|
||||
expose:
|
||||
- "9000"
|
||||
links:
|
||||
- workspace
|
||||
|
||||
### HHVM Container ##########################################
|
||||
|
||||
hhvm:
|
||||
@ -144,16 +161,20 @@ services:
|
||||
links:
|
||||
- beanstalkd
|
||||
|
||||
### Workspace Utilities Container ###########################
|
||||
### Caddy Server Container ##################################
|
||||
|
||||
workspace:
|
||||
build:
|
||||
context: ./workspace
|
||||
args:
|
||||
- INSTALL_PRESTISSIMO=false
|
||||
caddy:
|
||||
build: ./caddy
|
||||
volumes_from:
|
||||
- volumes_source
|
||||
tty: true
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
- "2015:2015"
|
||||
volumes:
|
||||
- ./caddy/Caddyfile:/etc/Caddyfile
|
||||
links:
|
||||
- php-fpm
|
||||
|
||||
### Laravel Application Code Container ######################
|
||||
|
||||
@ -174,21 +195,5 @@ services:
|
||||
- /var/lib/redis:/data
|
||||
- /var/lib/neo4j:/var/lib/neo4j/data
|
||||
- /var/lib/mongo:/data/db
|
||||
|
||||
### Caddy Server Container ##################################
|
||||
# Edit the Caddyfile if needed (./caddy/Caddyfile)
|
||||
|
||||
caddy:
|
||||
build: ./caddy
|
||||
volumes_from:
|
||||
- volumes_source
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
- "2015:2015"
|
||||
volumes:
|
||||
- ./caddy/Caddyfile:/etc/Caddyfile
|
||||
links:
|
||||
- php-fpm
|
||||
|
||||
### Add more Containers below ###############################
|
||||
|
@ -21,8 +21,8 @@ ADD ./laravel.pool.conf /usr/local/etc/php-fpm.d/
|
||||
|
||||
# Install "curl", "libmemcached-dev", "libpq-dev", "libjpeg-dev",
|
||||
# "libpng12-dev", "libfreetype6-dev", "libssl-dev", "libmcrypt-dev",
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
libmemcached-dev \
|
||||
libz-dev \
|
||||
@ -43,18 +43,26 @@ RUN docker-php-ext-install pdo_mysql
|
||||
RUN docker-php-ext-install pdo_pgsql
|
||||
|
||||
# Install the PHP gd library
|
||||
RUN docker-php-ext-install gd \
|
||||
&& docker-php-ext-configure gd \
|
||||
RUN docker-php-ext-install gd && \
|
||||
docker-php-ext-configure gd \
|
||||
--enable-gd-native-ttf \
|
||||
--with-jpeg-dir=/usr/lib \
|
||||
--with-freetype-dir=/usr/include/freetype2
|
||||
|
||||
# Install the mongodb extention
|
||||
RUN pecl install mongodb
|
||||
ARG INSTALL_MONGO=true
|
||||
ENV INSTALL_MONGO ${INSTALL_MONGO}
|
||||
RUN if [ ${INSTALL_MONGO} = true ]; then \
|
||||
# Install the mongodb extention
|
||||
pecl install mongodb \
|
||||
;fi
|
||||
|
||||
# Install the xdebug extention
|
||||
RUN pecl install xdebug \
|
||||
&& docker-php-ext-enable xdebug
|
||||
ARG INSTALL_XDEBUG=true
|
||||
ENV INSTALL_XDEBUG ${INSTALL_XDEBUG}
|
||||
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
|
||||
# Install the xdebug extention
|
||||
pecl install xdebug && \
|
||||
docker-php-ext-enable xdebug \
|
||||
;fi
|
||||
|
||||
#
|
||||
#--------------------------------------------------------------------------
|
||||
|
@ -21,8 +21,8 @@ ADD ./laravel.pool.conf /usr/local/etc/php-fpm.d/
|
||||
|
||||
# Install "curl", "libmemcached-dev", "libpq-dev", "libjpeg-dev",
|
||||
# "libpng12-dev", "libfreetype6-dev", "libssl-dev", "libmcrypt-dev",
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
libmemcached-dev \
|
||||
libz-dev \
|
||||
@ -43,18 +43,26 @@ RUN docker-php-ext-install pdo_mysql
|
||||
RUN docker-php-ext-install pdo_pgsql
|
||||
|
||||
# Install the PHP gd library
|
||||
RUN docker-php-ext-install gd \
|
||||
&& docker-php-ext-configure gd \
|
||||
RUN docker-php-ext-install gd && \
|
||||
docker-php-ext-configure gd \
|
||||
--enable-gd-native-ttf \
|
||||
--with-jpeg-dir=/usr/lib \
|
||||
--with-freetype-dir=/usr/include/freetype2
|
||||
|
||||
# Install the mongodb extention
|
||||
RUN pecl install mongodb
|
||||
ARG INSTALL_MONGO=true
|
||||
ENV INSTALL_MONGO ${INSTALL_MONGO}
|
||||
RUN if [ ${INSTALL_MONGO} = true ]; then \
|
||||
# Install the mongodb extention
|
||||
pecl install mongodb \
|
||||
;fi
|
||||
|
||||
# Install the xdebug extention
|
||||
RUN pecl install xdebug \
|
||||
&& docker-php-ext-enable xdebug
|
||||
ARG INSTALL_XDEBUG=true
|
||||
ENV INSTALL_XDEBUG ${INSTALL_XDEBUG}
|
||||
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
|
||||
# Install the xdebug extention
|
||||
pecl install xdebug && \
|
||||
docker-php-ext-enable xdebug \
|
||||
;fi
|
||||
|
||||
# Install the memcached extention
|
||||
RUN curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached-dev/php-memcached/archive/php7.tar.gz" \
|
||||
|
@ -17,22 +17,19 @@ ENV LC_CTYPE=UTF-8
|
||||
ENV LANG=en_US.UTF-8
|
||||
ENV TERM xterm
|
||||
|
||||
# Add the "PHP 7" ppa
|
||||
RUN apt-get install -y software-properties-common && \
|
||||
add-apt-repository -y ppa:ondrej/php
|
||||
|
||||
#
|
||||
#--------------------------------------------------------------------------
|
||||
# Software's Installation
|
||||
#--------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
# Install "software-properties-common" (for the "add-apt-repository")
|
||||
RUN apt-get update && apt-get install -y \
|
||||
software-properties-common
|
||||
|
||||
# Add the "PHP 7" ppa
|
||||
RUN add-apt-repository -y \
|
||||
ppa:ondrej/php
|
||||
|
||||
# Install "PHP-CLI 7", "PHP extentions", "useful Tools"
|
||||
RUN apt-get update && apt-get install -y --force-yes \
|
||||
# Install "PHP Extentions", "libraries", "Software's"
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --force-yes \
|
||||
php7.0-cli \
|
||||
php7.0-common \
|
||||
php7.0-curl \
|
||||
@ -47,53 +44,65 @@ RUN apt-get update && apt-get install -y --force-yes \
|
||||
php7.0-zip \
|
||||
php7.0-memcached \
|
||||
php7.0-gd \
|
||||
php7.0-xdebug \
|
||||
pkg-config \
|
||||
php-dev \
|
||||
libcurl4-openssl-dev \
|
||||
libedit-dev \
|
||||
libssl-dev \
|
||||
libxml2-dev \
|
||||
xz-utils \
|
||||
sqlite3 \
|
||||
libsqlite3-dev \
|
||||
sqlite3 \
|
||||
git \
|
||||
curl \
|
||||
vim \
|
||||
nano \
|
||||
pkg-config
|
||||
|
||||
# Clean up now, to free up some space
|
||||
RUN apt-get clean
|
||||
&& apt-get clean
|
||||
|
||||
# Composer: Install composer and add its bin to the PATH.
|
||||
RUN curl -s http://getcomposer.org/installer | php \
|
||||
&& echo "export PATH=${PATH}:/var/www/laravel/vendor/bin" >> ~/.bashrc \
|
||||
&& mv composer.phar /usr/local/bin/composer
|
||||
RUN curl -s http://getcomposer.org/installer | php && \
|
||||
echo "export PATH=${PATH}:/var/www/laravel/vendor/bin" >> ~/.bashrc && \
|
||||
mv composer.phar /usr/local/bin/composer
|
||||
|
||||
# Prestissimo: Install Prestissimo (A Composer parallel install plugin)
|
||||
ARG INSTALL_PRESTISSIMO=false
|
||||
RUN if [ "$INSTALL_PRESTISSIMO" = true ] ; then \
|
||||
composer global require "hirak/prestissimo:^0.3"; \
|
||||
fi
|
||||
ARG INSTALL_PRESTISSIMO=true
|
||||
ENV INSTALL_PRESTISSIMO ${INSTALL_PRESTISSIMO}
|
||||
RUN if [ ${INSTALL_PRESTISSIMO} = true ]; then \
|
||||
# Prestissimo: Install Prestissimo (A Composer parallel install plugin)
|
||||
composer global require "hirak/prestissimo:^0.3" \
|
||||
;fi
|
||||
|
||||
# MongoDB: Install the mongodb extension
|
||||
RUN pecl install mongodb \
|
||||
&& echo "extension=mongodb.so" >> /etc/php/7.0/cli/php.ini
|
||||
ARG INSTALL_MONGO=true
|
||||
ENV INSTALL_MONGO ${INSTALL_MONGO}
|
||||
RUN if [ ${INSTALL_MONGO} = true ]; then \
|
||||
# MongoDB: Install the mongodb extension
|
||||
pecl install mongodb && \
|
||||
echo "extension=mongodb.so" >> /etc/php/7.0/cli/php.ini \
|
||||
;fi
|
||||
|
||||
# XDebug: Load the xdebug extension only with phpunit commands
|
||||
RUN sed -i 's/^/;/g' /etc/php/7.0/cli/conf.d/20-xdebug.ini \
|
||||
&& echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/laravel/vendor/bin/phpunit'" >> ~/.bashrc
|
||||
ARG INSTALL_XDEBUG=true
|
||||
ENV INSTALL_XDEBUG ${INSTALL_XDEBUG}
|
||||
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
|
||||
# XDebug: Load the xdebug extension only with phpunit commands
|
||||
apt-get install -y --force-yes php7.0-xdebug && \
|
||||
sed -i 's/^/;/g' /etc/php/7.0/cli/conf.d/20-xdebug.ini && \
|
||||
echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/laravel/vendor/bin/phpunit'" >> ~/.bashrc \
|
||||
;fi
|
||||
|
||||
# NVM: Install nvm (A Node Version Manager)
|
||||
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash
|
||||
ENV NVM_DIR=/root/.nvm
|
||||
|
||||
# Node: Install node
|
||||
RUN . ~/.nvm/nvm.sh \
|
||||
&& nvm install stable \
|
||||
&& nvm use stable \
|
||||
&& nvm alias stable \
|
||||
&& npm install -g gulp bower
|
||||
ARG INSTALL_NODE=true
|
||||
ENV INSTALL_NODE ${INSTALL_NODE}
|
||||
RUN if [ ${INSTALL_NODE} = true ]; then \
|
||||
# Node: Install nvm (A Node Version Manager) and use it to install NodeJS
|
||||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash \
|
||||
;fi
|
||||
ENV if [ ${INSTALL_NODE} = true ]; then \
|
||||
# I had to split this condifiton link this because when I get it inside the above if statment is refuses to work!
|
||||
NVM_DIR=/root/.nvm \
|
||||
RUN . ~/.nvm/nvm.sh && \
|
||||
nvm install stable && \
|
||||
nvm use stable && \
|
||||
nvm alias stable && \
|
||||
npm install -g gulp bower \
|
||||
;fi
|
||||
|
||||
#
|
||||
#--------------------------------------------------------------------------
|
||||
@ -105,7 +114,8 @@ RUN . ~/.nvm/nvm.sh \
|
||||
RUN . ~/.bashrc
|
||||
|
||||
# Clean up
|
||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
RUN apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
WORKDIR /var/www/laravel
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user