Skip to content

Commit 062b746

Browse files
committed
add composer.json to install global composer dependencies
1 parent e1dbb97 commit 062b746

File tree

4 files changed

+83
-27
lines changed

4 files changed

+83
-27
lines changed

README.md

+38-14
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ It's like Laravel Homestead but for Docker instead of Vagrant.
5353
- [Run a Docker Virtual Host](#Run-Docker-Virtual-Host)
5454
- [Find your Docker IP Address](#Find-Docker-IP-Address)
5555
- [Use custom Domain](#Use-custom-Domain)
56+
- [Enable Global Composer Build Install](#Enable-Global-Composer-Build-Install)
5657
- [Install Prestissimo](#Install-Prestissimo)
5758
- [Install Node + NVM](#Install-Node)
5859
- [Debugging](#debugging)
@@ -608,7 +609,7 @@ It should be like this:
608609
...
609610
```
610611

611-
2 - Re-build the containers docker-compose build workspace php-fpm
612+
2 - Re-build the containers `docker-compose build workspace php-fpm`
612613

613614

614615

@@ -800,9 +801,7 @@ It should be like this:
800801
...
801802
```
802803

803-
2 - Re-build the containers docker-compose build workspace php-fpm
804-
805-
3 - Use it
804+
2 - Re-build the containers `docker-compose build workspace php-fpm`
806805

807806

808807

@@ -906,17 +905,16 @@ server_name laravel.dev;
906905
```
907906

908907

909-
<br>
910-
<a name="Install-Prestissimo"></a>
911-
### Install Prestissimo
912908

913-
[Prestissimo](https://github.com/hirak/prestissimo) is a plugin for composer which enables parallel install functionality.
909+
<br>
910+
<a name="Enable-Global-Composer-Build-Install"></a>
911+
### Enable Global Composer Build Install
914912

915-
To install Prestissimo in the Workspace container
913+
To enable Running Global Composer Install during the Build:
916914

917-
1 - Open the `docker-compose.yml` file
915+
1 - open the `docker-compose.yml` file
918916

919-
2 - Search for the `INSTALL_PRESTISSIMO` argument under the Workspace Container and set it to `true`
917+
2 - search for the `COMPOSER_GLOBAL_INSTALL` argument under the Workspace Container and set it to `true`
920918

921919
It should be like this:
922920

@@ -925,11 +923,37 @@ It should be like this:
925923
build:
926924
context: ./workspace
927925
args:
928-
- INSTALL_PRESTISSIMO=true
926+
- COMPOSER_GLOBAL_INSTALL=true
929927
...
930928
```
929+
3 - now add your dependencies to `workspace/composer.json`
930+
931+
4 - rebuild the Workspace Container `docker-compose build workspace`
932+
933+
934+
935+
936+
<br>
937+
<a name="Install-Prestissimo"></a>
938+
### Install Prestissimo
939+
940+
[Prestissimo](https://github.com/hirak/prestissimo) is a plugin for composer which enables parallel install functionality.
941+
942+
1 - Enable Running Global Composer Install during the Build:
943+
944+
Click on this [Enable Global Composer Build Install](#Enable-Global-Composer-Build-Install) and do steps 1 and 2 only then continue here.
945+
946+
2 - Add prestissimo as requirement in Composer:
947+
948+
a - now open the `workspace/composer.json` file
949+
950+
b - add `"hirak/prestissimo": "^0.3"` as requirement
951+
952+
c - rebuild the Workspace Container `docker-compose build workspace`
953+
954+
955+
931956

932-
3 - Re-build the container docker-compose build workspace
933957

934958
<a name="Install-Node"></a>
935959
### Install Node + NVM
@@ -951,7 +975,7 @@ It should be like this:
951975
...
952976
```
953977

954-
3 - Re-build the container docker-compose build workspace
978+
3 - Re-build the container `docker-compose build workspace`
955979

956980
<br>
957981
<a name="debugging"></a>

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
- INSTALL_MONGO=false
1212
- INSTALL_XDEBUG=false
1313
- INSTALL_NODE=false
14-
- INSTALL_PRESTISSIMO=false
14+
- COMPOSER_GLOBAL_INSTALL=false
1515
volumes_from:
1616
- volumes_source
1717
tty: true

workspace/Dockerfile

+39-12
Original file line numberDiff line numberDiff line change
@@ -59,44 +59,71 @@ RUN apt-get update && \
5959
nano \
6060
&& apt-get clean
6161

62-
# Composer: Install composer and add its bin to the PATH.
62+
#####################################
63+
# Composer:
64+
#####################################
65+
66+
# Install composer and add its bin to the PATH.
6367
RUN curl -s http://getcomposer.org/installer | php && \
6468
echo "export PATH=${PATH}:/var/www/laravel/vendor/bin" >> ~/.bashrc && \
6569
mv composer.phar /usr/local/bin/composer
6670

67-
ARG INSTALL_PRESTISSIMO=true
68-
ENV INSTALL_PRESTISSIMO ${INSTALL_PRESTISSIMO}
71+
# Add the composer.json
72+
ADD ./composer.json /root/.composer/composer.json
73+
74+
# Check if global install need to be runned
75+
ARG COMPOSER_GLOBAL_INSTALL=true
76+
ENV COMPOSER_GLOBAL_INSTALL ${COMPOSER_GLOBAL_INSTALL}
6977
RUN if [ ${INSTALL_PRESTISSIMO} = true ]; then \
70-
# Prestissimo: Install Prestissimo (A Composer parallel install plugin)
71-
composer global require "hirak/prestissimo:^0.3" \
78+
# run the install
79+
composer global install \
7280
;fi
7381

82+
83+
#####################################
84+
# MongoDB:
85+
#####################################
86+
87+
# Check if Mongo needs to be installed
7488
ARG INSTALL_MONGO=true
7589
ENV INSTALL_MONGO ${INSTALL_MONGO}
7690
RUN if [ ${INSTALL_MONGO} = true ]; then \
77-
# MongoDB: Install the mongodb extension
91+
# Install the mongodb extension
7892
pecl install mongodb && \
79-
echo "extension=mongodb.so" >> /etc/php/7.0/cli/php.ini \
93+
echo "extension=mongodb.so" >> /etc/php/7.0/cli/php.ini \
8094
;fi
8195

96+
#####################################
97+
# xDebug:
98+
#####################################
99+
100+
# Check if xDebug needs to be installed
82101
ARG INSTALL_XDEBUG=true
83102
ENV INSTALL_XDEBUG ${INSTALL_XDEBUG}
84103
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
85-
# XDebug: Load the xdebug extension only with phpunit commands
104+
# Load the xdebug extension only with phpunit commands
86105
apt-get install -y --force-yes php7.0-xdebug && \
87-
sed -i 's/^/;/g' /etc/php/7.0/cli/conf.d/20-xdebug.ini && \
88-
echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/laravel/vendor/bin/phpunit'" >> ~/.bashrc \
106+
sed -i 's/^/;/g' /etc/php/7.0/cli/conf.d/20-xdebug.ini && \
107+
echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/laravel/vendor/bin/phpunit'" >> ~/.bashrc \
89108
;fi
90109

110+
#####################################
111+
# Node / NVM:
112+
#####################################
113+
114+
# Check if NVM needs to be installed
91115
ARG INSTALL_NODE=true
92116
ENV INSTALL_NODE ${INSTALL_NODE}
93117
RUN if [ ${INSTALL_NODE} = true ]; then \
94-
# Node: Install nvm (A Node Version Manager) and use it to install NodeJS
118+
# Install nvm (A Node Version Manager)
95119
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash \
96120
;fi
121+
# Again check if NVM needs to be installed
122+
# I had to split this condifiton link this because when I get it inside the above if statment is refuses to work!
97123
ENV if [ ${INSTALL_NODE} = true ]; then \
98-
# I had to split this condifiton link this because when I get it inside the above if statment is refuses to work!
124+
# Set the ENV
99125
NVM_DIR=/root/.nvm \
126+
# Install NodeJS with NVM
100127
RUN . ~/.nvm/nvm.sh && \
101128
nvm install stable && \
102129
nvm use stable && \

workspace/composer.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
4+
}
5+
}

0 commit comments

Comments
 (0)