@@ -7,9 +7,9 @@ Repository: https://github.com/TrafeX/docker-php-nginx
7
7
8
8
* Built on the lightweight and secure Alpine Linux distribution
9
9
* 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
11
11
* 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)
13
13
* The servers Nginx, PHP-FPM and supervisord run under a non-privileged user (nobody) to make it more secure
14
14
* The logs of all the services are redirected to the output of the Docker container (visible with ` docker logs -f <container name> ` )
15
15
* 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
62
62
63
63
## Adding composer
64
64
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.
66
66
67
67
``` dockerfile
68
68
FROM trafex/alpine-nginx-php7:latest
@@ -73,3 +73,26 @@ COPY --from=composer /usr/bin/composer /usr/bin/composer
73
73
# Run composer install to install the dependencies
74
74
RUN composer install --optimize-autoloader --no-interaction --no-progress
75
75
```
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