Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Use envvar DOCUMENT_ROOT in nginx.conf (#270)
Browse files Browse the repository at this point in the history
* Use envvar DOCUMENT_ROOT in nginx.conf

* Removed a wrong comment

* Use /app since ${APP_DIR} is not available on the same line
  • Loading branch information
Takashi Matsuo authored May 4, 2017
1 parent e646931 commit 73e8407
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
3 changes: 2 additions & 1 deletion php-nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ ENV NGINX_DIR=/etc/nginx \
PHP70_VERSION=7.0.15 \
PHP71_VERSION=7.1.1 \
PATH=/opt/php/bin:$PATH \
WWW_HOME=/var/www
WWW_HOME=/var/www \
DOCUMENT_ROOT=/app

# Install build scripts - composer, nginx, php
COPY build-scripts /build-scripts
Expand Down
2 changes: 1 addition & 1 deletion php-nginx/build-scripts/install_nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
# A shell script for installing nginx.
set -xe

apt-get install -y nginx --no-install-recommends
apt-get install -y nginx-extras --no-install-recommends
9 changes: 0 additions & 9 deletions php-nginx/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,6 @@ session.save_path="${MEMCACHE_PORT_11211_TCP_ADDR}:${MEMCACHE_PORT_11211_TCP_POR
EOF
fi

# Configure document root in php.ini and nginx.conf with DOCUMENT_ROOT
# environment variable or APP_DIR if DOCUMENT_ROOT is not set.

if [ -z "${DOCUMENT_ROOT}" ]; then
DOCUMENT_ROOT="${APP_DIR}"
fi

sed -i "s|%%DOC_ROOT%%|${DOCUMENT_ROOT}|g" "${NGINX_DIR}/nginx.conf"

if [ -f "${APP_DIR}/composer.json" ]; then
# run the composer scripts for post-deploy
if su www-data -c "php /usr/local/bin/composer --no-ansi run-script -l" \
Expand Down
7 changes: 6 additions & 1 deletion php-nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

daemon off;

env DOCUMENT_ROOT;

user www-data;
worker_processes auto;
error_log /dev/stderr info;
Expand Down Expand Up @@ -47,8 +49,11 @@ http {
}

server {

set_by_lua $docroot 'return os.getenv("DOCUMENT_ROOT")';

listen 8080;
root %%DOC_ROOT%%;
root $docroot;
index index.php index.html index.htm;

# Media: images, icons, video, audio, HTC
Expand Down

0 comments on commit 73e8407

Please sign in to comment.