Skip to content

Commit

Permalink
Merge pull request #122 from tiangolo/custom-nginx-conf
Browse files Browse the repository at this point in the history
Add support for custom /app/nginx.conf
  • Loading branch information
tiangolo authored Feb 2, 2019
2 parents 9b041e2 + e1dce06 commit fa9d991
Show file tree
Hide file tree
Showing 24 changed files with 452 additions and 190 deletions.
42 changes: 23 additions & 19 deletions python2.7-alpine3.7/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,30 @@ USE_STATIC_PATH=${STATIC_PATH:-'/app/static'}
# Get the listen port for Nginx, default to 80
USE_LISTEN_PORT=${LISTEN_PORT:-80}

content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
if [ -f /app/nginx.conf ]; then
cp /app/nginx.conf /etc/nginx/nginx.conf
else
content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
content_server=$content_server' }\n'
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf

exec "$@"
42 changes: 23 additions & 19 deletions python2.7-alpine3.8/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,30 @@ USE_STATIC_PATH=${STATIC_PATH:-'/app/static'}
# Get the listen port for Nginx, default to 80
USE_LISTEN_PORT=${LISTEN_PORT:-80}

content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
if [ -f /app/nginx.conf ]; then
cp /app/nginx.conf /etc/nginx/nginx.conf
else
content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
content_server=$content_server' }\n'
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf

exec "$@"
42 changes: 23 additions & 19 deletions python2.7/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,30 @@ USE_STATIC_PATH=${STATIC_PATH:-'/app/static'}
# Get the listen port for Nginx, default to 80
USE_LISTEN_PORT=${LISTEN_PORT:-80}

content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
if [ -f /app/nginx.conf ]; then
cp /app/nginx.conf /etc/nginx/nginx.conf
else
content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
content_server=$content_server' }\n'
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf

exec "$@"
42 changes: 23 additions & 19 deletions python3.5/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,30 @@ USE_STATIC_PATH=${STATIC_PATH:-'/app/static'}
# Get the listen port for Nginx, default to 80
USE_LISTEN_PORT=${LISTEN_PORT:-80}

content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
if [ -f /app/nginx.conf ]; then
cp /app/nginx.conf /etc/nginx/nginx.conf
else
content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
content_server=$content_server' }\n'
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf

exec "$@"
42 changes: 23 additions & 19 deletions python3.6-alpine3.7/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,30 @@ USE_STATIC_PATH=${STATIC_PATH:-'/app/static'}
# Get the listen port for Nginx, default to 80
USE_LISTEN_PORT=${LISTEN_PORT:-80}

content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
if [ -f /app/nginx.conf ]; then
cp /app/nginx.conf /etc/nginx/nginx.conf
else
content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
content_server=$content_server' }\n'
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf

exec "$@"
42 changes: 23 additions & 19 deletions python3.6-alpine3.8/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,30 @@ USE_STATIC_PATH=${STATIC_PATH:-'/app/static'}
# Get the listen port for Nginx, default to 80
USE_LISTEN_PORT=${LISTEN_PORT:-80}

content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
if [ -f /app/nginx.conf ]; then
cp /app/nginx.conf /etc/nginx/nginx.conf
else
content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
content_server=$content_server' }\n'
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf

exec "$@"
42 changes: 23 additions & 19 deletions python3.6/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,30 @@ USE_STATIC_PATH=${STATIC_PATH:-'/app/static'}
# Get the listen port for Nginx, default to 80
USE_LISTEN_PORT=${LISTEN_PORT:-80}

content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
if [ -f /app/nginx.conf ]; then
cp /app/nginx.conf /etc/nginx/nginx.conf
else
content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
content_server=$content_server' }\n'
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf

exec "$@"
42 changes: 23 additions & 19 deletions python3.7-alpine3.7/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,30 @@ USE_STATIC_PATH=${STATIC_PATH:-'/app/static'}
# Get the listen port for Nginx, default to 80
USE_LISTEN_PORT=${LISTEN_PORT:-80}

content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
if [ -f /app/nginx.conf ]; then
cp /app/nginx.conf /etc/nginx/nginx.conf
else
content_server='server {\n'
content_server=$content_server" listen ${USE_LISTEN_PORT};\n"
content_server=$content_server' location / {\n'
content_server=$content_server' try_files $uri @app;\n'
content_server=$content_server' }\n'
content_server=$content_server' location @app {\n'
content_server=$content_server' include uwsgi_params;\n'
content_server=$content_server' uwsgi_pass unix:///tmp/uwsgi.sock;\n'
content_server=$content_server' }\n'
content_server=$content_server" location $USE_STATIC_URL {\n"
content_server=$content_server" alias $USE_STATIC_PATH;\n"
content_server=$content_server' }\n'
# If STATIC_INDEX is 1, serve / with /static/index.html directly (or the static URL configured)
if [ "$STATIC_INDEX" = 1 ] ; then
content_server=$content_server' location = / {\n'
content_server=$content_server" index $USE_STATIC_URL/index.html;\n"
content_server=$content_server' }\n'
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf
fi
content_server=$content_server'}\n'
# Save generated server /etc/nginx/conf.d/nginx.conf
printf "$content_server" > /etc/nginx/conf.d/nginx.conf

exec "$@"
Loading

0 comments on commit fa9d991

Please sign in to comment.