diff --git a/python2.7-alpine3.7/entrypoint.sh b/python2.7-alpine3.7/entrypoint.sh index 8071431..4998f88 100644 --- a/python2.7-alpine3.7/entrypoint.sh +++ b/python2.7-alpine3.7/entrypoint.sh @@ -18,44 +18,48 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-1024} # Get the listen port for Nginx, default to 80 USE_LISTEN_PORT=${LISTEN_PORT:-80} -content='user nginx;\n' -# Set the number of worker processes in Nginx -content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" -content=$content'error_log /var/log/nginx/error.log warn;\n' -content=$content'pid /var/run/nginx.pid;\n' -content=$content'events {\n' -content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" -content=$content'}\n' -content=$content'http {\n' -content=$content' include /etc/nginx/mime.types;\n' -content=$content' default_type application/octet-stream;\n' -content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" -content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" -content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" -content=$content' access_log /var/log/nginx/access.log main;\n' -content=$content' sendfile on;\n' -content=$content' keepalive_timeout 65;\n' -content=$content' include /etc/nginx/conf.d/*.conf;\n' -content=$content'}\n' -content=$content'daemon off;\n' -# Set the max number of open file descriptors for Nginx workers, if requested -if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then - content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" +if [ -f /app/nginx.conf ]; then + cp /app/nginx.conf /etc/nginx/nginx.conf +else + content='user nginx;\n' + # Set the number of worker processes in Nginx + content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" + content=$content'error_log /var/log/nginx/error.log warn;\n' + content=$content'pid /var/run/nginx.pid;\n' + content=$content'events {\n' + content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" + content=$content'}\n' + content=$content'http {\n' + content=$content' include /etc/nginx/mime.types;\n' + content=$content' default_type application/octet-stream;\n' + content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" + content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" + content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" + content=$content' access_log /var/log/nginx/access.log main;\n' + content=$content' sendfile on;\n' + content=$content' keepalive_timeout 65;\n' + content=$content' include /etc/nginx/conf.d/*.conf;\n' + content=$content'}\n' + content=$content'daemon off;\n' + # Set the max number of open file descriptors for Nginx workers, if requested + if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then + content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" + fi + # Save generated /etc/nginx/nginx.conf + printf "$content" > /etc/nginx/nginx.conf + + content_server='server {\n' + content_server=$content_server" listen ${USE_LISTEN_PORT};\n" + content_server=$content_server' location / {\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'}\n' + # Save generated server /etc/nginx/conf.d/nginx.conf + printf "$content_server" > /etc/nginx/conf.d/nginx.conf + + # Generate Nginx config for maximum upload file size + printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf fi -# Save generated /etc/nginx/nginx.conf -printf "$content" > /etc/nginx/nginx.conf - -content_server='server {\n' -content_server=$content_server" listen ${USE_LISTEN_PORT};\n" -content_server=$content_server' location / {\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'}\n' -# Save generated server /etc/nginx/conf.d/nginx.conf -printf "$content_server" > /etc/nginx/conf.d/nginx.conf - -# Generate Nginx config for maximum upload file size -printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf exec "$@" diff --git a/python2.7-alpine3.8/entrypoint.sh b/python2.7-alpine3.8/entrypoint.sh index 8071431..4998f88 100644 --- a/python2.7-alpine3.8/entrypoint.sh +++ b/python2.7-alpine3.8/entrypoint.sh @@ -18,44 +18,48 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-1024} # Get the listen port for Nginx, default to 80 USE_LISTEN_PORT=${LISTEN_PORT:-80} -content='user nginx;\n' -# Set the number of worker processes in Nginx -content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" -content=$content'error_log /var/log/nginx/error.log warn;\n' -content=$content'pid /var/run/nginx.pid;\n' -content=$content'events {\n' -content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" -content=$content'}\n' -content=$content'http {\n' -content=$content' include /etc/nginx/mime.types;\n' -content=$content' default_type application/octet-stream;\n' -content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" -content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" -content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" -content=$content' access_log /var/log/nginx/access.log main;\n' -content=$content' sendfile on;\n' -content=$content' keepalive_timeout 65;\n' -content=$content' include /etc/nginx/conf.d/*.conf;\n' -content=$content'}\n' -content=$content'daemon off;\n' -# Set the max number of open file descriptors for Nginx workers, if requested -if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then - content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" +if [ -f /app/nginx.conf ]; then + cp /app/nginx.conf /etc/nginx/nginx.conf +else + content='user nginx;\n' + # Set the number of worker processes in Nginx + content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" + content=$content'error_log /var/log/nginx/error.log warn;\n' + content=$content'pid /var/run/nginx.pid;\n' + content=$content'events {\n' + content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" + content=$content'}\n' + content=$content'http {\n' + content=$content' include /etc/nginx/mime.types;\n' + content=$content' default_type application/octet-stream;\n' + content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" + content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" + content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" + content=$content' access_log /var/log/nginx/access.log main;\n' + content=$content' sendfile on;\n' + content=$content' keepalive_timeout 65;\n' + content=$content' include /etc/nginx/conf.d/*.conf;\n' + content=$content'}\n' + content=$content'daemon off;\n' + # Set the max number of open file descriptors for Nginx workers, if requested + if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then + content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" + fi + # Save generated /etc/nginx/nginx.conf + printf "$content" > /etc/nginx/nginx.conf + + content_server='server {\n' + content_server=$content_server" listen ${USE_LISTEN_PORT};\n" + content_server=$content_server' location / {\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'}\n' + # Save generated server /etc/nginx/conf.d/nginx.conf + printf "$content_server" > /etc/nginx/conf.d/nginx.conf + + # Generate Nginx config for maximum upload file size + printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf fi -# Save generated /etc/nginx/nginx.conf -printf "$content" > /etc/nginx/nginx.conf - -content_server='server {\n' -content_server=$content_server" listen ${USE_LISTEN_PORT};\n" -content_server=$content_server' location / {\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'}\n' -# Save generated server /etc/nginx/conf.d/nginx.conf -printf "$content_server" > /etc/nginx/conf.d/nginx.conf - -# Generate Nginx config for maximum upload file size -printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf exec "$@" diff --git a/python2.7/entrypoint.sh b/python2.7/entrypoint.sh index 5306a8a..343dda1 100644 --- a/python2.7/entrypoint.sh +++ b/python2.7/entrypoint.sh @@ -14,44 +14,48 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-1024} # Get the listen port for Nginx, default to 80 USE_LISTEN_PORT=${LISTEN_PORT:-80} -content='user nginx;\n' -# Set the number of worker processes in Nginx -content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" -content=$content'error_log /var/log/nginx/error.log warn;\n' -content=$content'pid /var/run/nginx.pid;\n' -content=$content'events {\n' -content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" -content=$content'}\n' -content=$content'http {\n' -content=$content' include /etc/nginx/mime.types;\n' -content=$content' default_type application/octet-stream;\n' -content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" -content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" -content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" -content=$content' access_log /var/log/nginx/access.log main;\n' -content=$content' sendfile on;\n' -content=$content' keepalive_timeout 65;\n' -content=$content' include /etc/nginx/conf.d/*.conf;\n' -content=$content'}\n' -content=$content'daemon off;\n' -# Set the max number of open file descriptors for Nginx workers, if requested -if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then - content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" +if [ -f /app/nginx.conf ]; then + cp /app/nginx.conf /etc/nginx/nginx.conf +else + content='user nginx;\n' + # Set the number of worker processes in Nginx + content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" + content=$content'error_log /var/log/nginx/error.log warn;\n' + content=$content'pid /var/run/nginx.pid;\n' + content=$content'events {\n' + content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" + content=$content'}\n' + content=$content'http {\n' + content=$content' include /etc/nginx/mime.types;\n' + content=$content' default_type application/octet-stream;\n' + content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" + content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" + content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" + content=$content' access_log /var/log/nginx/access.log main;\n' + content=$content' sendfile on;\n' + content=$content' keepalive_timeout 65;\n' + content=$content' include /etc/nginx/conf.d/*.conf;\n' + content=$content'}\n' + content=$content'daemon off;\n' + # Set the max number of open file descriptors for Nginx workers, if requested + if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then + content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" + fi + # Save generated /etc/nginx/nginx.conf + printf "$content" > /etc/nginx/nginx.conf + + content_server='server {\n' + content_server=$content_server" listen ${USE_LISTEN_PORT};\n" + content_server=$content_server' location / {\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'}\n' + # Save generated server /etc/nginx/conf.d/nginx.conf + printf "$content_server" > /etc/nginx/conf.d/nginx.conf + + # Generate Nginx config for maximum upload file size + printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf fi -# Save generated /etc/nginx/nginx.conf -printf "$content" > /etc/nginx/nginx.conf - -content_server='server {\n' -content_server=$content_server" listen ${USE_LISTEN_PORT};\n" -content_server=$content_server' location / {\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'}\n' -# Save generated server /etc/nginx/conf.d/nginx.conf -printf "$content_server" > /etc/nginx/conf.d/nginx.conf - -# Generate Nginx config for maximum upload file size -printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf exec "$@" diff --git a/python3.5/entrypoint.sh b/python3.5/entrypoint.sh index 5306a8a..343dda1 100644 --- a/python3.5/entrypoint.sh +++ b/python3.5/entrypoint.sh @@ -14,44 +14,48 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-1024} # Get the listen port for Nginx, default to 80 USE_LISTEN_PORT=${LISTEN_PORT:-80} -content='user nginx;\n' -# Set the number of worker processes in Nginx -content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" -content=$content'error_log /var/log/nginx/error.log warn;\n' -content=$content'pid /var/run/nginx.pid;\n' -content=$content'events {\n' -content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" -content=$content'}\n' -content=$content'http {\n' -content=$content' include /etc/nginx/mime.types;\n' -content=$content' default_type application/octet-stream;\n' -content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" -content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" -content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" -content=$content' access_log /var/log/nginx/access.log main;\n' -content=$content' sendfile on;\n' -content=$content' keepalive_timeout 65;\n' -content=$content' include /etc/nginx/conf.d/*.conf;\n' -content=$content'}\n' -content=$content'daemon off;\n' -# Set the max number of open file descriptors for Nginx workers, if requested -if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then - content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" +if [ -f /app/nginx.conf ]; then + cp /app/nginx.conf /etc/nginx/nginx.conf +else + content='user nginx;\n' + # Set the number of worker processes in Nginx + content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" + content=$content'error_log /var/log/nginx/error.log warn;\n' + content=$content'pid /var/run/nginx.pid;\n' + content=$content'events {\n' + content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" + content=$content'}\n' + content=$content'http {\n' + content=$content' include /etc/nginx/mime.types;\n' + content=$content' default_type application/octet-stream;\n' + content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" + content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" + content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" + content=$content' access_log /var/log/nginx/access.log main;\n' + content=$content' sendfile on;\n' + content=$content' keepalive_timeout 65;\n' + content=$content' include /etc/nginx/conf.d/*.conf;\n' + content=$content'}\n' + content=$content'daemon off;\n' + # Set the max number of open file descriptors for Nginx workers, if requested + if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then + content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" + fi + # Save generated /etc/nginx/nginx.conf + printf "$content" > /etc/nginx/nginx.conf + + content_server='server {\n' + content_server=$content_server" listen ${USE_LISTEN_PORT};\n" + content_server=$content_server' location / {\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'}\n' + # Save generated server /etc/nginx/conf.d/nginx.conf + printf "$content_server" > /etc/nginx/conf.d/nginx.conf + + # Generate Nginx config for maximum upload file size + printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf fi -# Save generated /etc/nginx/nginx.conf -printf "$content" > /etc/nginx/nginx.conf - -content_server='server {\n' -content_server=$content_server" listen ${USE_LISTEN_PORT};\n" -content_server=$content_server' location / {\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'}\n' -# Save generated server /etc/nginx/conf.d/nginx.conf -printf "$content_server" > /etc/nginx/conf.d/nginx.conf - -# Generate Nginx config for maximum upload file size -printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf exec "$@" diff --git a/python3.6-alpine3.7/entrypoint.sh b/python3.6-alpine3.7/entrypoint.sh index 0edd595..7c7d99f 100644 --- a/python3.6-alpine3.7/entrypoint.sh +++ b/python3.6-alpine3.7/entrypoint.sh @@ -18,44 +18,48 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-1024} # Get the listen port for Nginx, default to 80 USE_LISTEN_PORT=${LISTEN_PORT:-80} -content='user nginx;\n' -# Set the number of worker processes in Nginx -content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" -content=$content'error_log /var/log/nginx/error.log warn;\n' -content=$content'pid /var/run/nginx.pid;\n' -content=$content'events {\n' -content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" -content=$content'}\n' -content=$content'http {\n' -content=$content' include /etc/nginx/mime.types;\n' -content=$content' default_type application/octet-stream;\n' -content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" -content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" -content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" -content=$content' access_log /var/log/nginx/access.log main;\n' -content=$content' sendfile on;\n' -content=$content' keepalive_timeout 65;\n' -content=$content' include /etc/nginx/conf.d/*.conf;\n' -content=$content'}\n' -content=$content'daemon off;\n' -# Set the max number of open file descriptors for Nginx workers, if requested -if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then - content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" +if [ -f /app/nginx.conf ]; then + cp /app/nginx.conf /etc/nginx/nginx.conf +else + content='user nginx;\n' + # Set the number of worker processes in Nginx + content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" + content=$content'error_log /var/log/nginx/error.log warn;\n' + content=$content'pid /var/run/nginx.pid;\n' + content=$content'events {\n' + content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" + content=$content'}\n' + content=$content'http {\n' + content=$content' include /etc/nginx/mime.types;\n' + content=$content' default_type application/octet-stream;\n' + content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" + content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" + content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" + content=$content' access_log /var/log/nginx/access.log main;\n' + content=$content' sendfile on;\n' + content=$content' keepalive_timeout 65;\n' + content=$content' include /etc/nginx/conf.d/*.conf;\n' + content=$content'}\n' + content=$content'daemon off;\n' + # Set the max number of open file descriptors for Nginx workers, if requested + if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then + content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" + fi + # Save generated /etc/nginx/nginx.conf + printf "$content" > /etc/nginx/nginx.conf + + content_server='server {\n' + content_server=$content_server" listen ${USE_LISTEN_PORT};\n" + content_server=$content_server' location / {\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'}\n' + # Save generated server /etc/nginx/conf.d/nginx.conf + printf "$content_server" > /etc/nginx/conf.d/nginx.conf + + # Generate Nginx config for maximum upload file size + printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf fi -# Save generated /etc/nginx/nginx.conf -printf "$content" > /etc/nginx/nginx.conf - -content_server='server {\n' -content_server=$content_server" listen ${USE_LISTEN_PORT};\n" -content_server=$content_server' location / {\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'}\n' -# Save generated server /etc/nginx/conf.d/nginx.conf -printf "$content_server" > /etc/nginx/conf.d/nginx.conf - -# Generate Nginx config for maximum upload file size -printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf exec "$@" diff --git a/python3.6-alpine3.8/entrypoint.sh b/python3.6-alpine3.8/entrypoint.sh index 0edd595..7c7d99f 100644 --- a/python3.6-alpine3.8/entrypoint.sh +++ b/python3.6-alpine3.8/entrypoint.sh @@ -18,44 +18,48 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-1024} # Get the listen port for Nginx, default to 80 USE_LISTEN_PORT=${LISTEN_PORT:-80} -content='user nginx;\n' -# Set the number of worker processes in Nginx -content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" -content=$content'error_log /var/log/nginx/error.log warn;\n' -content=$content'pid /var/run/nginx.pid;\n' -content=$content'events {\n' -content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" -content=$content'}\n' -content=$content'http {\n' -content=$content' include /etc/nginx/mime.types;\n' -content=$content' default_type application/octet-stream;\n' -content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" -content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" -content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" -content=$content' access_log /var/log/nginx/access.log main;\n' -content=$content' sendfile on;\n' -content=$content' keepalive_timeout 65;\n' -content=$content' include /etc/nginx/conf.d/*.conf;\n' -content=$content'}\n' -content=$content'daemon off;\n' -# Set the max number of open file descriptors for Nginx workers, if requested -if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then - content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" +if [ -f /app/nginx.conf ]; then + cp /app/nginx.conf /etc/nginx/nginx.conf +else + content='user nginx;\n' + # Set the number of worker processes in Nginx + content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" + content=$content'error_log /var/log/nginx/error.log warn;\n' + content=$content'pid /var/run/nginx.pid;\n' + content=$content'events {\n' + content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" + content=$content'}\n' + content=$content'http {\n' + content=$content' include /etc/nginx/mime.types;\n' + content=$content' default_type application/octet-stream;\n' + content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" + content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" + content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" + content=$content' access_log /var/log/nginx/access.log main;\n' + content=$content' sendfile on;\n' + content=$content' keepalive_timeout 65;\n' + content=$content' include /etc/nginx/conf.d/*.conf;\n' + content=$content'}\n' + content=$content'daemon off;\n' + # Set the max number of open file descriptors for Nginx workers, if requested + if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then + content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" + fi + # Save generated /etc/nginx/nginx.conf + printf "$content" > /etc/nginx/nginx.conf + + content_server='server {\n' + content_server=$content_server" listen ${USE_LISTEN_PORT};\n" + content_server=$content_server' location / {\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'}\n' + # Save generated server /etc/nginx/conf.d/nginx.conf + printf "$content_server" > /etc/nginx/conf.d/nginx.conf + + # Generate Nginx config for maximum upload file size + printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf fi -# Save generated /etc/nginx/nginx.conf -printf "$content" > /etc/nginx/nginx.conf - -content_server='server {\n' -content_server=$content_server" listen ${USE_LISTEN_PORT};\n" -content_server=$content_server' location / {\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'}\n' -# Save generated server /etc/nginx/conf.d/nginx.conf -printf "$content_server" > /etc/nginx/conf.d/nginx.conf - -# Generate Nginx config for maximum upload file size -printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf exec "$@" diff --git a/python3.6/entrypoint.sh b/python3.6/entrypoint.sh index 5306a8a..343dda1 100644 --- a/python3.6/entrypoint.sh +++ b/python3.6/entrypoint.sh @@ -14,44 +14,48 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-1024} # Get the listen port for Nginx, default to 80 USE_LISTEN_PORT=${LISTEN_PORT:-80} -content='user nginx;\n' -# Set the number of worker processes in Nginx -content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" -content=$content'error_log /var/log/nginx/error.log warn;\n' -content=$content'pid /var/run/nginx.pid;\n' -content=$content'events {\n' -content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" -content=$content'}\n' -content=$content'http {\n' -content=$content' include /etc/nginx/mime.types;\n' -content=$content' default_type application/octet-stream;\n' -content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" -content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" -content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" -content=$content' access_log /var/log/nginx/access.log main;\n' -content=$content' sendfile on;\n' -content=$content' keepalive_timeout 65;\n' -content=$content' include /etc/nginx/conf.d/*.conf;\n' -content=$content'}\n' -content=$content'daemon off;\n' -# Set the max number of open file descriptors for Nginx workers, if requested -if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then - content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" +if [ -f /app/nginx.conf ]; then + cp /app/nginx.conf /etc/nginx/nginx.conf +else + content='user nginx;\n' + # Set the number of worker processes in Nginx + content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" + content=$content'error_log /var/log/nginx/error.log warn;\n' + content=$content'pid /var/run/nginx.pid;\n' + content=$content'events {\n' + content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" + content=$content'}\n' + content=$content'http {\n' + content=$content' include /etc/nginx/mime.types;\n' + content=$content' default_type application/octet-stream;\n' + content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" + content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" + content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" + content=$content' access_log /var/log/nginx/access.log main;\n' + content=$content' sendfile on;\n' + content=$content' keepalive_timeout 65;\n' + content=$content' include /etc/nginx/conf.d/*.conf;\n' + content=$content'}\n' + content=$content'daemon off;\n' + # Set the max number of open file descriptors for Nginx workers, if requested + if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then + content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" + fi + # Save generated /etc/nginx/nginx.conf + printf "$content" > /etc/nginx/nginx.conf + + content_server='server {\n' + content_server=$content_server" listen ${USE_LISTEN_PORT};\n" + content_server=$content_server' location / {\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'}\n' + # Save generated server /etc/nginx/conf.d/nginx.conf + printf "$content_server" > /etc/nginx/conf.d/nginx.conf + + # Generate Nginx config for maximum upload file size + printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf fi -# Save generated /etc/nginx/nginx.conf -printf "$content" > /etc/nginx/nginx.conf - -content_server='server {\n' -content_server=$content_server" listen ${USE_LISTEN_PORT};\n" -content_server=$content_server' location / {\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'}\n' -# Save generated server /etc/nginx/conf.d/nginx.conf -printf "$content_server" > /etc/nginx/conf.d/nginx.conf - -# Generate Nginx config for maximum upload file size -printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf exec "$@" diff --git a/python3.7-alpine3.7/entrypoint.sh b/python3.7-alpine3.7/entrypoint.sh index e07e2c8..5a34417 100644 --- a/python3.7-alpine3.7/entrypoint.sh +++ b/python3.7-alpine3.7/entrypoint.sh @@ -18,44 +18,48 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-1024} # Get the listen port for Nginx, default to 80 USE_LISTEN_PORT=${LISTEN_PORT:-80} -content='user nginx;\n' -# Set the number of worker processes in Nginx -content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" -content=$content'error_log /var/log/nginx/error.log warn;\n' -content=$content'pid /var/run/nginx.pid;\n' -content=$content'events {\n' -content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" -content=$content'}\n' -content=$content'http {\n' -content=$content' include /etc/nginx/mime.types;\n' -content=$content' default_type application/octet-stream;\n' -content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" -content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" -content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" -content=$content' access_log /var/log/nginx/access.log main;\n' -content=$content' sendfile on;\n' -content=$content' keepalive_timeout 65;\n' -content=$content' include /etc/nginx/conf.d/*.conf;\n' -content=$content'}\n' -content=$content'daemon off;\n' -# Set the max number of open file descriptors for Nginx workers, if requested -if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then - content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" +if [ -f /app/nginx.conf ]; then + cp /app/nginx.conf /etc/nginx/nginx.conf +else + content='user nginx;\n' + # Set the number of worker processes in Nginx + content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" + content=$content'error_log /var/log/nginx/error.log warn;\n' + content=$content'pid /var/run/nginx.pid;\n' + content=$content'events {\n' + content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" + content=$content'}\n' + content=$content'http {\n' + content=$content' include /etc/nginx/mime.types;\n' + content=$content' default_type application/octet-stream;\n' + content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" + content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" + content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" + content=$content' access_log /var/log/nginx/access.log main;\n' + content=$content' sendfile on;\n' + content=$content' keepalive_timeout 65;\n' + content=$content' include /etc/nginx/conf.d/*.conf;\n' + content=$content'}\n' + content=$content'daemon off;\n' + # Set the max number of open file descriptors for Nginx workers, if requested + if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then + content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" + fi + # Save generated /etc/nginx/nginx.conf + printf "$content" > /etc/nginx/nginx.conf + + content_server='server {\n' + content_server=$content_server" listen ${USE_LISTEN_PORT};\n" + content_server=$content_server' location / {\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'}\n' + # Save generated server /etc/nginx/conf.d/nginx.conf + printf "$content_server" > /etc/nginx/conf.d/nginx.conf + + # Generate Nginx config for maximum upload file size + printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf fi -# Save generated /etc/nginx/nginx.conf -printf "$content" > /etc/nginx/nginx.conf - -content_server='server {\n' -content_server=$content_server" listen ${USE_LISTEN_PORT};\n" -content_server=$content_server' location / {\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'}\n' -# Save generated server /etc/nginx/conf.d/nginx.conf -printf "$content_server" > /etc/nginx/conf.d/nginx.conf - -# Generate Nginx config for maximum upload file size -printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf exec "$@" diff --git a/python3.7-alpine3.8/entrypoint.sh b/python3.7-alpine3.8/entrypoint.sh index e07e2c8..5a34417 100644 --- a/python3.7-alpine3.8/entrypoint.sh +++ b/python3.7-alpine3.8/entrypoint.sh @@ -18,44 +18,48 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-1024} # Get the listen port for Nginx, default to 80 USE_LISTEN_PORT=${LISTEN_PORT:-80} -content='user nginx;\n' -# Set the number of worker processes in Nginx -content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" -content=$content'error_log /var/log/nginx/error.log warn;\n' -content=$content'pid /var/run/nginx.pid;\n' -content=$content'events {\n' -content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" -content=$content'}\n' -content=$content'http {\n' -content=$content' include /etc/nginx/mime.types;\n' -content=$content' default_type application/octet-stream;\n' -content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" -content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" -content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" -content=$content' access_log /var/log/nginx/access.log main;\n' -content=$content' sendfile on;\n' -content=$content' keepalive_timeout 65;\n' -content=$content' include /etc/nginx/conf.d/*.conf;\n' -content=$content'}\n' -content=$content'daemon off;\n' -# Set the max number of open file descriptors for Nginx workers, if requested -if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then - content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" +if [ -f /app/nginx.conf ]; then + cp /app/nginx.conf /etc/nginx/nginx.conf +else + content='user nginx;\n' + # Set the number of worker processes in Nginx + content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" + content=$content'error_log /var/log/nginx/error.log warn;\n' + content=$content'pid /var/run/nginx.pid;\n' + content=$content'events {\n' + content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" + content=$content'}\n' + content=$content'http {\n' + content=$content' include /etc/nginx/mime.types;\n' + content=$content' default_type application/octet-stream;\n' + content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" + content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" + content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" + content=$content' access_log /var/log/nginx/access.log main;\n' + content=$content' sendfile on;\n' + content=$content' keepalive_timeout 65;\n' + content=$content' include /etc/nginx/conf.d/*.conf;\n' + content=$content'}\n' + content=$content'daemon off;\n' + # Set the max number of open file descriptors for Nginx workers, if requested + if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then + content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" + fi + # Save generated /etc/nginx/nginx.conf + printf "$content" > /etc/nginx/nginx.conf + + content_server='server {\n' + content_server=$content_server" listen ${USE_LISTEN_PORT};\n" + content_server=$content_server' location / {\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'}\n' + # Save generated server /etc/nginx/conf.d/nginx.conf + printf "$content_server" > /etc/nginx/conf.d/nginx.conf + + # Generate Nginx config for maximum upload file size + printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf fi -# Save generated /etc/nginx/nginx.conf -printf "$content" > /etc/nginx/nginx.conf - -content_server='server {\n' -content_server=$content_server" listen ${USE_LISTEN_PORT};\n" -content_server=$content_server' location / {\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'}\n' -# Save generated server /etc/nginx/conf.d/nginx.conf -printf "$content_server" > /etc/nginx/conf.d/nginx.conf - -# Generate Nginx config for maximum upload file size -printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf exec "$@" diff --git a/python3.7/entrypoint.sh b/python3.7/entrypoint.sh index 5306a8a..343dda1 100644 --- a/python3.7/entrypoint.sh +++ b/python3.7/entrypoint.sh @@ -14,44 +14,48 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-1024} # Get the listen port for Nginx, default to 80 USE_LISTEN_PORT=${LISTEN_PORT:-80} -content='user nginx;\n' -# Set the number of worker processes in Nginx -content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" -content=$content'error_log /var/log/nginx/error.log warn;\n' -content=$content'pid /var/run/nginx.pid;\n' -content=$content'events {\n' -content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" -content=$content'}\n' -content=$content'http {\n' -content=$content' include /etc/nginx/mime.types;\n' -content=$content' default_type application/octet-stream;\n' -content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" -content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" -content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" -content=$content' access_log /var/log/nginx/access.log main;\n' -content=$content' sendfile on;\n' -content=$content' keepalive_timeout 65;\n' -content=$content' include /etc/nginx/conf.d/*.conf;\n' -content=$content'}\n' -content=$content'daemon off;\n' -# Set the max number of open file descriptors for Nginx workers, if requested -if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then - content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" +if [ -f /app/nginx.conf ]; then + cp /app/nginx.conf /etc/nginx/nginx.conf +else + content='user nginx;\n' + # Set the number of worker processes in Nginx + content=$content"worker_processes ${USE_NGINX_WORKER_PROCESSES};\n" + content=$content'error_log /var/log/nginx/error.log warn;\n' + content=$content'pid /var/run/nginx.pid;\n' + content=$content'events {\n' + content=$content" worker_connections ${NGINX_WORKER_CONNECTIONS};\n" + content=$content'}\n' + content=$content'http {\n' + content=$content' include /etc/nginx/mime.types;\n' + content=$content' default_type application/octet-stream;\n' + content=$content' log_format main '"'\$remote_addr - \$remote_user [\$time_local] \"\$request\" '\n" + content=$content' '"'\$status \$body_bytes_sent \"\$http_referer\" '\n" + content=$content' '"'\"\$http_user_agent\" \"\$http_x_forwarded_for\"';\n" + content=$content' access_log /var/log/nginx/access.log main;\n' + content=$content' sendfile on;\n' + content=$content' keepalive_timeout 65;\n' + content=$content' include /etc/nginx/conf.d/*.conf;\n' + content=$content'}\n' + content=$content'daemon off;\n' + # Set the max number of open file descriptors for Nginx workers, if requested + if [ -n "${NGINX_WORKER_OPEN_FILES}" ] ; then + content=$content"worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};\n" + fi + # Save generated /etc/nginx/nginx.conf + printf "$content" > /etc/nginx/nginx.conf + + content_server='server {\n' + content_server=$content_server" listen ${USE_LISTEN_PORT};\n" + content_server=$content_server' location / {\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'}\n' + # Save generated server /etc/nginx/conf.d/nginx.conf + printf "$content_server" > /etc/nginx/conf.d/nginx.conf + + # Generate Nginx config for maximum upload file size + printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf fi -# Save generated /etc/nginx/nginx.conf -printf "$content" > /etc/nginx/nginx.conf - -content_server='server {\n' -content_server=$content_server" listen ${USE_LISTEN_PORT};\n" -content_server=$content_server' location / {\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'}\n' -# Save generated server /etc/nginx/conf.d/nginx.conf -printf "$content_server" > /etc/nginx/conf.d/nginx.conf - -# Generate Nginx config for maximum upload file size -printf "client_max_body_size $USE_NGINX_MAX_UPLOAD;\n" > /etc/nginx/conf.d/upload.conf exec "$@" diff --git a/tests/test_02_app/custom_nginx_app/app/main.py b/tests/test_02_app/custom_nginx_app/app/main.py new file mode 100644 index 0000000..8033a67 --- /dev/null +++ b/tests/test_02_app/custom_nginx_app/app/main.py @@ -0,0 +1,10 @@ +import sys + + +def application(env, start_response): + version = "{}.{}".format(sys.version_info.major, sys.version_info.minor) + start_response("200 OK", [("Content-Type", "text/plain")]) + message = "Hello World from Nginx uWSGI Python {} app in a Docker container".format( + version + ) + return [message.encode("utf-8")] diff --git a/tests/test_02_app/custom_nginx_app/app/nginx.conf b/tests/test_02_app/custom_nginx_app/app/nginx.conf new file mode 100644 index 0000000..91365b9 --- /dev/null +++ b/tests/test_02_app/custom_nginx_app/app/nginx.conf @@ -0,0 +1,25 @@ +user nginx; +worker_processes 2; +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; +events { + worker_connections 2048; +} +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + access_log /var/log/nginx/access.log main; + sendfile on; + keepalive_timeout 300; + server { + listen 8080; + location / { + include uwsgi_params; + uwsgi_pass unix:///tmp/uwsgi.sock; + } + } +} +daemon off; diff --git a/tests/test_02_app/custom_nginx_app/latest.dockerfile b/tests/test_02_app/custom_nginx_app/latest.dockerfile new file mode 100644 index 0000000..2232d39 --- /dev/null +++ b/tests/test_02_app/custom_nginx_app/latest.dockerfile @@ -0,0 +1,3 @@ +FROM tiangolo/uwsgi-nginx:latest + +COPY app /app diff --git a/tests/test_02_app/custom_nginx_app/python2.7-alpine3.7.dockerfile b/tests/test_02_app/custom_nginx_app/python2.7-alpine3.7.dockerfile new file mode 100644 index 0000000..26ad9a5 --- /dev/null +++ b/tests/test_02_app/custom_nginx_app/python2.7-alpine3.7.dockerfile @@ -0,0 +1,3 @@ +FROM tiangolo/uwsgi-nginx:python2.7-alpine3.7 + +COPY app /app \ No newline at end of file diff --git a/tests/test_02_app/custom_nginx_app/python2.7-alpine3.8.dockerfile b/tests/test_02_app/custom_nginx_app/python2.7-alpine3.8.dockerfile new file mode 100644 index 0000000..40ccdcc --- /dev/null +++ b/tests/test_02_app/custom_nginx_app/python2.7-alpine3.8.dockerfile @@ -0,0 +1,3 @@ +FROM tiangolo/uwsgi-nginx:python2.7-alpine3.8 + +COPY app /app diff --git a/tests/test_02_app/custom_nginx_app/python2.7.dockerfile b/tests/test_02_app/custom_nginx_app/python2.7.dockerfile new file mode 100644 index 0000000..96c7d3c --- /dev/null +++ b/tests/test_02_app/custom_nginx_app/python2.7.dockerfile @@ -0,0 +1,3 @@ +FROM tiangolo/uwsgi-nginx:python2.7 + +COPY app /app diff --git a/tests/test_02_app/custom_nginx_app/python3.5.dockerfile b/tests/test_02_app/custom_nginx_app/python3.5.dockerfile new file mode 100644 index 0000000..f20bde3 --- /dev/null +++ b/tests/test_02_app/custom_nginx_app/python3.5.dockerfile @@ -0,0 +1,3 @@ +FROM tiangolo/uwsgi-nginx:python3.5 + +COPY app /app diff --git a/tests/test_02_app/custom_nginx_app/python3.6-alpine3.7.dockerfile b/tests/test_02_app/custom_nginx_app/python3.6-alpine3.7.dockerfile new file mode 100644 index 0000000..8a4a434 --- /dev/null +++ b/tests/test_02_app/custom_nginx_app/python3.6-alpine3.7.dockerfile @@ -0,0 +1,3 @@ +FROM tiangolo/uwsgi-nginx:python3.6-alpine3.7 + +COPY app /app diff --git a/tests/test_02_app/custom_nginx_app/python3.6-alpine3.8.dockerfile b/tests/test_02_app/custom_nginx_app/python3.6-alpine3.8.dockerfile new file mode 100644 index 0000000..cd890ef --- /dev/null +++ b/tests/test_02_app/custom_nginx_app/python3.6-alpine3.8.dockerfile @@ -0,0 +1,3 @@ +FROM tiangolo/uwsgi-nginx:python3.6-alpine3.8 + +COPY app /app diff --git a/tests/test_02_app/custom_nginx_app/python3.6.dockerfile b/tests/test_02_app/custom_nginx_app/python3.6.dockerfile new file mode 100644 index 0000000..77ea266 --- /dev/null +++ b/tests/test_02_app/custom_nginx_app/python3.6.dockerfile @@ -0,0 +1,3 @@ +FROM tiangolo/uwsgi-nginx:python3.6 + +COPY app /app diff --git a/tests/test_02_app/custom_nginx_app/python3.7-alpine3.7.dockerfile b/tests/test_02_app/custom_nginx_app/python3.7-alpine3.7.dockerfile new file mode 100644 index 0000000..3dd26af --- /dev/null +++ b/tests/test_02_app/custom_nginx_app/python3.7-alpine3.7.dockerfile @@ -0,0 +1,3 @@ +FROM tiangolo/uwsgi-nginx:python3.7-alpine3.7 + +COPY app /app diff --git a/tests/test_02_app/custom_nginx_app/python3.7-alpine3.8.dockerfile b/tests/test_02_app/custom_nginx_app/python3.7-alpine3.8.dockerfile new file mode 100644 index 0000000..54b4cc5 --- /dev/null +++ b/tests/test_02_app/custom_nginx_app/python3.7-alpine3.8.dockerfile @@ -0,0 +1,3 @@ +FROM tiangolo/uwsgi-nginx:python3.7-alpine3.8 + +COPY app /app diff --git a/tests/test_02_app/custom_nginx_app/python3.7.dockerfile b/tests/test_02_app/custom_nginx_app/python3.7.dockerfile new file mode 100644 index 0000000..fedf2ed --- /dev/null +++ b/tests/test_02_app/custom_nginx_app/python3.7.dockerfile @@ -0,0 +1,3 @@ +FROM tiangolo/uwsgi-nginx:python3.7 + +COPY app /app diff --git a/tests/test_02_app/test_custom_nginx_app.py b/tests/test_02_app/test_custom_nginx_app.py new file mode 100644 index 0000000..5840ff0 --- /dev/null +++ b/tests/test_02_app/test_custom_nginx_app.py @@ -0,0 +1,122 @@ +import time +from pathlib import Path, PurePath + +import docker +import pytest +import requests + +from ..utils import ( + CONTAINER_NAME, + get_logs, + get_nginx_config, + remove_previous_container, +) + +client = docker.from_env() + + +def verify_container(container, response_text): + nginx_config = get_nginx_config(container) + assert "client_max_body_size 0;" not in nginx_config + assert "worker_processes 2;" in nginx_config + assert "listen 8080;" in nginx_config + assert "worker_connections 2048;" in nginx_config + assert "worker_rlimit_nofile;" not in nginx_config + assert "daemon off;" in nginx_config + assert "include uwsgi_params;" in nginx_config + assert "uwsgi_pass unix:///tmp/uwsgi.sock;" in nginx_config + assert "keepalive_timeout 300;" in nginx_config + logs = get_logs(container) + assert "getting INI configuration from /app/uwsgi.ini" in logs + assert "getting INI configuration from /etc/uwsgi/uwsgi.ini" in logs + assert "ini = /app/uwsgi.ini" in logs + assert "ini = /etc/uwsgi/uwsgi.ini" in logs + assert "socket = /tmp/uwsgi.sock" in logs + assert "chown-socket = nginx:nginx" in logs + assert "chmod-socket = 664" in logs + assert "hook-master-start = unix_signal:15 gracefully_kill_them_all" in logs + assert "need-app = true" in logs + assert "die-on-term = true" in logs + assert "show-config = true" in logs + assert "wsgi-file = /app/main.py" in logs + assert "processes = 16" in logs + assert "cheaper = 2" in logs + assert "spawned uWSGI master process" in logs + assert "spawned uWSGI worker 1" in logs + assert "spawned uWSGI worker 2" in logs + assert "spawned uWSGI worker 3" not in logs + assert 'running "unix_signal:15 gracefully_kill_them_all" (master-start)' in logs + assert "success: nginx entered RUNNING state, process has stayed up for" in logs + assert "success: uwsgi entered RUNNING state, process has stayed up for" in logs + response = requests.get("http://127.0.0.1:8080") + assert response.status_code == 200 + assert response.text == response_text + + +@pytest.mark.parametrize( + "dockerfile,response_text", + [ + ( + "python2.7.dockerfile", + "Hello World from Nginx uWSGI Python 2.7 app in a Docker container", + ), + ( + "python2.7-alpine3.7.dockerfile", + "Hello World from Nginx uWSGI Python 2.7 app in a Docker container", + ), + ( + "python2.7-alpine3.8.dockerfile", + "Hello World from Nginx uWSGI Python 2.7 app in a Docker container", + ), + ( + "python3.5.dockerfile", + "Hello World from Nginx uWSGI Python 3.5 app in a Docker container", + ), + ( + "python3.6.dockerfile", + "Hello World from Nginx uWSGI Python 3.6 app in a Docker container", + ), + ( + "python3.6-alpine3.7.dockerfile", + "Hello World from Nginx uWSGI Python 3.6 app in a Docker container", + ), + ( + "python3.6-alpine3.8.dockerfile", + "Hello World from Nginx uWSGI Python 3.6 app in a Docker container", + ), + ( + "python3.7.dockerfile", + "Hello World from Nginx uWSGI Python 3.7 app in a Docker container", + ), + ( + "latest.dockerfile", + "Hello World from Nginx uWSGI Python 3.7 app in a Docker container", + ), + # ( + # "python3.7-alpine3.7.dockerfile", + # "Hello World from Nginx uWSGI Python 3.7 app in a Docker container", + # ), + # ( + # "python3.7-alpine3.8.dockerfile", + # "Hello World from Nginx uWSGI Python 3.7 app in a Docker container", + # ), + ], +) +def test_env_vars_1(dockerfile, response_text): + remove_previous_container(client) + tag = "uwsgi-nginx-testimage" + test_path: PurePath = Path(__file__) + path = test_path.parent / "custom_nginx_app" + client.images.build(path=str(path), dockerfile=dockerfile, tag=tag) + container = client.containers.run( + tag, name=CONTAINER_NAME, ports={"8080": "8080"}, detach=True + ) + time.sleep(3) + verify_container(container, response_text) + container.stop() + # Test that everything works after restarting too + container.start() + time.sleep(3) + verify_container(container, response_text) + container.stop() + container.remove()