@@ -7,9 +7,9 @@ Repository: https://github.com/TrafeX/docker-php-nginx
77
88* Built on the lightweight and secure Alpine Linux distribution
99* Very small Docker image size (+/-35MB)
10- * Uses PHP 7.3 for better performance, lower cpu usage & memory footprint
10+ * Uses PHP 7.3 for better performance, lower CPU usage & memory footprint
1111* Optimized for 100 concurrent users
12- * Optimized to only use resources when there's traffic (by using PHP-FPM's ondemand PM)
12+ * Optimized to only use resources when there's traffic (by using PHP-FPM's on-demand PM)
1313* The servers Nginx, PHP-FPM and supervisord run under a non-privileged user (nobody) to make it more secure
1414* The logs of all the services are redirected to the output of the Docker container (visible with ` docker logs -f <container name> ` )
1515* Follows the KISS principle (Keep It Simple, Stupid) to make it easy to understand and adjust the image to your needs
@@ -62,7 +62,7 @@ _Note; Because `-v` requires an absolute path I've added `pwd` in the example to
6262
6363## Adding composer
6464
65- If you need composer in your project, here's an easy way to add it;
65+ If you need [ Composer ] ( https://getcomposer.org/ ) in your project, here's an easy way to add it.
6666
6767``` dockerfile
6868FROM trafex/alpine-nginx-php7:latest
@@ -73,3 +73,26 @@ COPY --from=composer /usr/bin/composer /usr/bin/composer
7373# Run composer install to install the dependencies
7474RUN composer install --optimize-autoloader --no-interaction --no-progress
7575```
76+
77+ ### Building with composer
78+
79+ If you are building an image with source code in it and dependencies managed by composer then the definition can be improved.
80+ The dependencies should be retrieved by the composer but the composer itself (` /usr/bin/composer ` ) is not necessary to be included in the image.
81+
82+ ``` Dockerfile
83+ FROM composer AS composer
84+
85+ # copying the source directory and install the dependencies with composer
86+ COPY <your_directory>/ /app
87+
88+ # run composer install to install the dependencies
89+ RUN composer install \
90+ --optimize-autoloader \
91+ --no-interaction \
92+ --no-progress
93+
94+ # continue stage build with the desired image and copy the source including the
95+ # dependencies downloaded by composer
96+ FROM trafex/alpine-nginx-php7
97+ COPY --chown=nginx --from=composer /app /var/www/html
98+ ```
0 commit comments