-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(4.6.0-non-alpine): image for testing
- Loading branch information
Showing
9 changed files
with
315 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 a default Nginx uWSGI Python {} app in a Docker container (default)".format( | ||
version | ||
) | ||
return [message.encode("utf-8")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#! /usr/bin/env sh | ||
|
||
echo "Running inside /app/prestart.sh, you could add migrations to this file, e.g.:" | ||
|
||
echo " | ||
#! /usr/bin/env bash | ||
# Let the DB start | ||
sleep 10; | ||
# Run migrations | ||
alembic upgrade head | ||
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[uwsgi] | ||
wsgi-file=/app/main.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# Get the maximum upload file size for Nginx, default to 0: unlimited | ||
USE_NGINX_MAX_UPLOAD=${NGINX_MAX_UPLOAD:-0} | ||
|
||
# Get the number of workers for Nginx, default to 1 | ||
USE_NGINX_WORKER_PROCESSES=${NGINX_WORKER_PROCESSES:-1} | ||
|
||
# Set the max number of connections per worker for Nginx, if requested | ||
# Cannot exceed worker_rlimit_nofile, see NGINX_WORKER_OPEN_FILES below | ||
NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-1024} | ||
|
||
# Get the listen port for Nginx, default to 80 | ||
USE_LISTEN_PORT=${LISTEN_PORT:-80} | ||
|
||
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 | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#! /usr/bin/env sh | ||
set -e | ||
|
||
# If there's a prestart.sh script in the /app directory, run it before starting | ||
PRE_START_PATH=/app/prestart.sh | ||
echo "Checking for script in $PRE_START_PATH" | ||
if [ -f $PRE_START_PATH ] ; then | ||
echo "Running script $PRE_START_PATH" | ||
. $PRE_START_PATH | ||
else | ||
echo "There is no script $PRE_START_PATH" | ||
fi | ||
|
||
# Start Supervisor, with Nginx and uWSGI | ||
exec /usr/bin/supervisord |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[supervisord] | ||
nodaemon=true | ||
|
||
[program:uwsgi] | ||
command=/usr/local/bin/uwsgi --ini /etc/uwsgi/uwsgi.ini | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stderr | ||
stderr_logfile_maxbytes=0 | ||
|
||
[program:nginx] | ||
command=/usr/sbin/nginx | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stderr | ||
stderr_logfile_maxbytes=0 | ||
# Graceful stop, see http://nginx.org/en/docs/control.html | ||
stopsignal=QUIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[uwsgi] | ||
socket = /tmp/uwsgi.sock | ||
chown-socket = nginx:nginx | ||
chmod-socket = 664 | ||
# Graceful shutdown on SIGTERM, see https://github.com/unbit/uwsgi/issues/849#issuecomment-118869386 | ||
hook-master-start = unix_signal:15 gracefully_kill_them_all | ||
need-app = true | ||
die-on-term = true | ||
# For debugging and testing | ||
show-config = true |