make the PHP_UPSTREAM config for NGINX and Apache identical

This commit is contained in:
Mahmoud Zalt 2017-08-04 00:50:20 +03:00
parent 004e4354aa
commit 5c0b8316b1
4 changed files with 19 additions and 11 deletions

View File

@ -2,9 +2,10 @@ FROM webdevops/apache:ubuntu-16.04
MAINTAINER Eric Pfeiffer <computerfr33k@users.noreply.github.com>
ARG PHP_SOCKET=php-fpm:9000
ARG PHP_UPSTREAM_CONTAINER=php-fpm
ARG PHP_UPSTREAM_PORT=9000
ENV WEB_PHP_SOCKET=$PHP_SOCKET
ENV WEB_PHP_SOCKET=${PHP_UPSTREAM_CONTAINER}:${PHP_UPSTREAM_PORT}
ENV WEB_DOCUMENT_ROOT=/var/www/public/

View File

@ -107,13 +107,14 @@ services:
networks:
- backend
### Nginx Server Container ##################################
### NGINX Server Container ##################################
nginx:
build:
context: ./nginx
args:
- PHP_UPSTREAM=php-fpm
- PHP_UPSTREAM_CONTAINER=${NGINX_PHP_UPSTREAM_CONTAINER}
- PHP_UPSTREAM_PORT=${NGINX_PHP_UPSTREAM_PORT}
volumes_from:
- applications
volumes:
@ -146,7 +147,8 @@ services:
build:
context: ./apache2
args:
- PHP_SOCKET=${PHP_SOCKET}
- PHP_UPSTREAM_CONTAINER=${APACHE_PHP_UPSTREAM_CONTAINER}
- PHP_UPSTREAM_PORT=${APACHE_PHP_UPSTREAM_PORT}
volumes_from:
- applications
volumes:

View File

@ -80,15 +80,17 @@ NGINX_HOST_HTTP_PORT=80
NGINX_HOST_HTTPS_PORT=443
NGINX_HOST_LOG_PATH=./logs/nginx/
NGINX_SITES_PATH=./nginx/sites/
NGINX_PHP_UPSTREAM_CONTAINER=php-fpm
NGINX_PHP_UPSTREAM_PORT=9000
### APACHE #############################################################################################################
APACHE_HOST_HTTP_PORT=80
APACHE_HOST_HTTPS_PORT=443
APACHE2_PHP_SOCKET=php-fpm:9000
APACHE_HOST_LOG_PATH=./logs/apache2
APACHE_SITES_PATH=./apache2/sites
PHP_SOCKET=php-fpm:9000
APACHE_PHP_UPSTREAM_CONTAINER=php-fpm
APACHE_PHP_UPSTREAM_PORT=9000
### MYSQL ##############################################################################################################

View File

@ -4,7 +4,8 @@ MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
ADD nginx.conf /etc/nginx/
ARG PHP_UPSTREAM=php-fpm
ARG PHP_UPSTREAM_CONTAINER=php-fpm
ARG PHP_UPSTREAM_PORT=9000
# fix a problem--#397, change application source from dl-cdn.alpinelinux.org to aliyun source.
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories
@ -12,9 +13,11 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories
RUN apk update \
&& apk upgrade \
&& apk add --no-cache bash \
&& adduser -D -H -u 1000 -s /bin/bash www-data \
&& rm /etc/nginx/conf.d/default.conf \
&& echo "upstream php-upstream { server ${PHP_UPSTREAM}:9000; }" > /etc/nginx/conf.d/upstream.conf
&& adduser -D -H -u 1000 -s /bin/bash www-data
# Set upstream conf and remove the default conf
RUN echo "upstream php-upstream { server ${PHP_UPSTREAM_CONTAINER}:${PHP_UPSTREAM_PORT}; }" > /etc/nginx/conf.d/upstream.conf \
&& rm /etc/nginx/conf.d/default.conf
CMD ["nginx"]