@@ -18,27 +18,31 @@ COPY --from=builder /usr/local/lib/php/extensions /usr/local/lib/php/extensions
1818COPY --from=builder /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d
1919COPY --from=builder /app /var/www/html
2020
21- # NGINX configuration is here intentionally
22- RUN apk add --no-cache nginx \
23- && mkdir -p /var/www/html/tmp \
24- && chown -R nobody:nobody /var/www/html \
25- && chmod -R 777 /var/www/html \
26- && mkdir -p /run/nginx \
27- && echo 'server { \
28- listen 80; \
29- root /var/www/html; \
30- index index.php; \
31- location / { \
32- try_files $uri $uri/ /index.php?$query_string; \
33- } \
34- location ~ \. php$ { \
35- fastcgi_pass 127.0.0.1:9000; \
36- fastcgi_index index.php; \
37- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; \
38- include fastcgi_params; \
39- } \
40- }' > /etc/nginx/http.d/default.conf
41-
42- EXPOSE 80
43-
44- CMD php-fpm -D && nginx -g 'daemon off;'
21+ RUN apk add --no-cache nginx gettext \
22+ && mkdir -p /var/www/html/tmp /run/nginx /var/cache/nginx /var/log/nginx \
23+ && chmod -R 777 /var/www/html /run/nginx /var/cache/nginx /var/log/nginx \
24+ && sed -i 's|^listen = .*|listen = 127.0.0.1:9000|' /usr/local/etc/php-fpm.d/www.conf
25+
26+ ENV PCA_NGINX_PORT=8080
27+
28+ # NGINX config template
29+ RUN printf 'server {\n \
30+ listen ${PCA_NGINX_PORT};\n \
31+ root /var/www/html;\n \
32+ index index.php;\n \
33+ location / {\n \
34+ try_files $uri $uri/ /index.php$is_args$args;\n \
35+ }\n \
36+ location ~ \\ .php$ {\n \
37+ fastcgi_pass 127.0.0.1:9000;\n \
38+ fastcgi_index index.php;\n \
39+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n \
40+ include fastcgi_params;\n \
41+ }\n \
42+ }\n ' > /etc/nginx/http.d/default.conf.template
43+
44+ EXPOSE 8080
45+
46+ CMD envsubst '${PCA_NGINX_PORT}' < /etc/nginx/http.d/default.conf.template > /etc/nginx/http.d/default.conf \
47+ && php-fpm -D \
48+ && nginx -g 'daemon off;'
0 commit comments