diff --git a/python3.7-alpine3.7/Dockerfile b/python3.7-alpine3.7/Dockerfile new file mode 100644 index 0000000..cbe9b39 --- /dev/null +++ b/python3.7-alpine3.7/Dockerfile @@ -0,0 +1,200 @@ +FROM python:3.7-alpine3.7 + +LABEL maintainer="Sebastian Ramirez " + +# Standard set up Nginx Alpine +# https://github.com/nginxinc/docker-nginx/blob/f8fad321cf58d5cbcafa3d9fa15314b8a77b5e65/mainline/alpine/Dockerfile + +ENV NGINX_VERSION 1.13.8 + +RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \ + && CONFIG="\ + --prefix=/etc/nginx \ + --sbin-path=/usr/sbin/nginx \ + --modules-path=/usr/lib/nginx/modules \ + --conf-path=/etc/nginx/nginx.conf \ + --error-log-path=/var/log/nginx/error.log \ + --http-log-path=/var/log/nginx/access.log \ + --pid-path=/var/run/nginx.pid \ + --lock-path=/var/run/nginx.lock \ + --http-client-body-temp-path=/var/cache/nginx/client_temp \ + --http-proxy-temp-path=/var/cache/nginx/proxy_temp \ + --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \ + --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \ + --http-scgi-temp-path=/var/cache/nginx/scgi_temp \ + --user=nginx \ + --group=nginx \ + --with-http_ssl_module \ + --with-http_realip_module \ + --with-http_addition_module \ + --with-http_sub_module \ + --with-http_dav_module \ + --with-http_flv_module \ + --with-http_mp4_module \ + --with-http_gunzip_module \ + --with-http_gzip_static_module \ + --with-http_random_index_module \ + --with-http_secure_link_module \ + --with-http_stub_status_module \ + --with-http_auth_request_module \ + --with-http_xslt_module=dynamic \ + --with-http_image_filter_module=dynamic \ + --with-http_geoip_module=dynamic \ + --with-threads \ + --with-stream \ + --with-stream_ssl_module \ + --with-stream_ssl_preread_module \ + --with-stream_realip_module \ + --with-stream_geoip_module=dynamic \ + --with-http_slice_module \ + --with-mail \ + --with-mail_ssl_module \ + --with-compat \ + --with-file-aio \ + --with-http_v2_module \ + " \ + && addgroup -S nginx \ + && adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \ + && apk add --no-cache --virtual .build-deps \ + gcc \ + libc-dev \ + make \ + openssl-dev \ + pcre-dev \ + zlib-dev \ + linux-headers \ + curl \ + gnupg \ + libxslt-dev \ + gd-dev \ + geoip-dev \ + && curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tar.gz \ + && curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz.asc -o nginx.tar.gz.asc \ + && export GNUPGHOME="$(mktemp -d)" \ + && found=''; \ + for server in \ + ha.pool.sks-keyservers.net \ + hkp://keyserver.ubuntu.com:80 \ + hkp://p80.pool.sks-keyservers.net:80 \ + pgp.mit.edu \ + ; do \ + echo "Fetching GPG key $GPG_KEYS from $server"; \ + gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \ + done; \ + test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \ + gpg --batch --verify nginx.tar.gz.asc nginx.tar.gz \ + && rm -r "$GNUPGHOME" nginx.tar.gz.asc \ + && mkdir -p /usr/src \ + && tar -zxC /usr/src -f nginx.tar.gz \ + && rm nginx.tar.gz \ + && cd /usr/src/nginx-$NGINX_VERSION \ + && ./configure $CONFIG --with-debug \ + && make -j$(getconf _NPROCESSORS_ONLN) \ + && mv objs/nginx objs/nginx-debug \ + && mv objs/ngx_http_xslt_filter_module.so objs/ngx_http_xslt_filter_module-debug.so \ + && mv objs/ngx_http_image_filter_module.so objs/ngx_http_image_filter_module-debug.so \ + && mv objs/ngx_http_geoip_module.so objs/ngx_http_geoip_module-debug.so \ + && mv objs/ngx_stream_geoip_module.so objs/ngx_stream_geoip_module-debug.so \ + && ./configure $CONFIG \ + && make -j$(getconf _NPROCESSORS_ONLN) \ + && make install \ + && rm -rf /etc/nginx/html/ \ + && mkdir /etc/nginx/conf.d/ \ + && mkdir -p /usr/share/nginx/html/ \ + && install -m644 html/index.html /usr/share/nginx/html/ \ + && install -m644 html/50x.html /usr/share/nginx/html/ \ + && install -m755 objs/nginx-debug /usr/sbin/nginx-debug \ + && install -m755 objs/ngx_http_xslt_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_xslt_filter_module-debug.so \ + && install -m755 objs/ngx_http_image_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_image_filter_module-debug.so \ + && install -m755 objs/ngx_http_geoip_module-debug.so /usr/lib/nginx/modules/ngx_http_geoip_module-debug.so \ + && install -m755 objs/ngx_stream_geoip_module-debug.so /usr/lib/nginx/modules/ngx_stream_geoip_module-debug.so \ + && ln -s ../../usr/lib/nginx/modules /etc/nginx/modules \ + && strip /usr/sbin/nginx* \ + && strip /usr/lib/nginx/modules/*.so \ + && rm -rf /usr/src/nginx-$NGINX_VERSION \ + \ + # Bring in gettext so we can get `envsubst`, then throw + # the rest away. To do this, we need to install `gettext` + # then move `envsubst` out of the way so `gettext` can + # be deleted completely, then move `envsubst` back. + && apk add --no-cache --virtual .gettext gettext \ + && mv /usr/bin/envsubst /tmp/ \ + \ + && runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' /usr/sbin/nginx /usr/lib/nginx/modules/*.so /tmp/envsubst \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )" \ + && apk add --no-cache --virtual .nginx-rundeps $runDeps \ + && apk del .build-deps \ + && apk del .gettext \ + && mv /tmp/envsubst /usr/local/bin/ \ + \ + # Bring in tzdata so users could set the timezones through the environment + # variables + && apk add --no-cache tzdata \ + \ + # forward request and error logs to docker log collector + && ln -sf /dev/stdout /var/log/nginx/access.log \ + && ln -sf /dev/stderr /var/log/nginx/error.log + +COPY nginx.conf /etc/nginx/nginx.conf + +# Standard set up Nginx finished + +EXPOSE 80 + + +# # Expose 443, in case of LTS / HTTPS +EXPOSE 443 + +# Install uWSGI +RUN apk add --no-cache uwsgi-python3 + +# Make NGINX run on the foreground +RUN echo "daemon off;" >> /etc/nginx/nginx.conf +# Copy the modified Nginx conf +COPY nginx-custom.conf /etc/nginx/conf.d/nginx.conf +# Copy the base uWSGI ini file to enable default dynamic uwsgi process number +COPY uwsgi.ini /etc/uwsgi/ + +# Install Supervisord +RUN apk add --no-cache supervisor +# Custom Supervisord config +COPY supervisord.ini /etc/supervisor.d/supervisord.ini + +# Which uWSGI .ini file should be used, to make it customizable +ENV UWSGI_INI /app/uwsgi.ini + +# By default, run 2 processes +ENV UWSGI_CHEAPER 2 + +# By default, when on demand, run up to 16 processes +ENV UWSGI_PROCESSES 16 + +# By default, allow unlimited file sizes, modify it to limit the file sizes +# To have a maximum of 1 MB (Nginx's default) change the line to: +ENV NGINX_MAX_UPLOAD 1m +ENV NGINX_MAX_UPLOAD 0 + +# By default, Nginx will run a single worker process, setting it to auto +# will create a worker for each CPU core +ENV NGINX_WORKER_PROCESSES 1 + +# By default, Nginx listens on port 80. +# To modify this, change LISTEN_PORT environment variable. +# (in a Dockerfile or with an option for `docker run`) +ENV LISTEN_PORT 80 + +# Copy the entrypoint that will generate Nginx additional configs +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["sh", "/entrypoint.sh"] + +# Add demo app +COPY ./app /app +WORKDIR /app + +CMD ["/usr/bin/supervisord"] diff --git a/python3.7-alpine3.7/app/main.py b/python3.7-alpine3.7/app/main.py new file mode 100644 index 0000000..216c258 --- /dev/null +++ b/python3.7-alpine3.7/app/main.py @@ -0,0 +1,4 @@ +def application(env, start_response): + start_response('200 OK', [('Content-Type', 'text/html')]) + return [b"Hello World from a default Nginx uWSGI Python 3.6 app in a\ + Docker container (default)"] diff --git a/python3.7-alpine3.7/app/uwsgi.ini b/python3.7-alpine3.7/app/uwsgi.ini new file mode 100644 index 0000000..8a29f73 --- /dev/null +++ b/python3.7-alpine3.7/app/uwsgi.ini @@ -0,0 +1,2 @@ +[uwsgi] +wsgi-file=/app/main.py diff --git a/python3.7-alpine3.7/entrypoint.sh b/python3.7-alpine3.7/entrypoint.sh new file mode 100644 index 0000000..890e4d0 --- /dev/null +++ b/python3.7-alpine3.7/entrypoint.sh @@ -0,0 +1,35 @@ +#!/bin/bash +set -e + +# Get the maximum upload file size for Nginx, default to 0: unlimited +USE_NGINX_MAX_UPLOAD=${NGINX_MAX_UPLOAD:-0} +# Generate Nginx config for maximum upload file size +echo "client_max_body_size $USE_NGINX_MAX_UPLOAD;" > /etc/nginx/conf.d/upload.conf + +# Explicitly add installed Python packages and uWSGI Python packages to PYTHONPATH +# Otherwise uWSGI can't import Flask +export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.6/site-packages:/usr/lib/python3.6/site-packages + +# Get the number of workers for Nginx, default to 1 +USE_NGINX_WORKER_PROCESSES=${NGINX_WORKER_PROCESSES:-1} +# Modify the number of worker processes in Nginx config +sed -i "/worker_processes\s/c\worker_processes ${USE_NGINX_WORKER_PROCESSES};" /etc/nginx/nginx.conf + +# Set the max number of connections per worker for Nginx, if requested +# Cannot exceed worker_rlimit_nofile, see NGINX_WORKER_OPEN_FILES below +if [[ -v NGINX_WORKER_CONNECTIONS ]] ; then + sed -i "/worker_connections\s/c\ worker_connections ${NGINX_WORKER_CONNECTIONS};" /etc/nginx/nginx.conf +fi + +# Set the max number of open file descriptors for Nginx workers, if requested +if [[ -v NGINX_WORKER_OPEN_FILES ]] ; then + echo "worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};" >> /etc/nginx/nginx.conf +fi + +# Get the listen port for Nginx, default to 80 +USE_LISTEN_PORT=${LISTEN_PORT:-80} +# Modify Nignx config for listen port +if ! grep -q "listen ${USE_LISTEN_PORT};" /etc/nginx/conf.d/nginx.conf ; then + sed -i -e "/server {/a\ listen ${USE_LISTEN_PORT};" /etc/nginx/conf.d/nginx.conf +fi +exec "$@" diff --git a/python3.7-alpine3.7/nginx-custom.conf b/python3.7-alpine3.7/nginx-custom.conf new file mode 100644 index 0000000..eca3646 --- /dev/null +++ b/python3.7-alpine3.7/nginx-custom.conf @@ -0,0 +1,6 @@ +server { + location / { + include uwsgi_params; + uwsgi_pass unix:///tmp/uwsgi.sock; + } +} \ No newline at end of file diff --git a/python3.7-alpine3.7/nginx.conf b/python3.7-alpine3.7/nginx.conf new file mode 100644 index 0000000..7271761 --- /dev/null +++ b/python3.7-alpine3.7/nginx.conf @@ -0,0 +1,31 @@ +user nginx; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +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; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; +} \ No newline at end of file diff --git a/python3.7-alpine3.7/supervisord.ini b/python3.7-alpine3.7/supervisord.ini new file mode 100644 index 0000000..3a63232 --- /dev/null +++ b/python3.7-alpine3.7/supervisord.ini @@ -0,0 +1,18 @@ +[supervisord] +nodaemon=true + +[program:uwsgi] +command=/usr/sbin/uwsgi --ini /etc/uwsgi/uwsgi.ini --die-on-term --need-app --plugin python3 +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 diff --git a/python3.7-alpine3.7/uwsgi.ini b/python3.7-alpine3.7/uwsgi.ini new file mode 100644 index 0000000..93ce92f --- /dev/null +++ b/python3.7-alpine3.7/uwsgi.ini @@ -0,0 +1,7 @@ +[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 \ No newline at end of file diff --git a/python3.7/Dockerfile b/python3.7/Dockerfile new file mode 100644 index 0000000..8bb2d49 --- /dev/null +++ b/python3.7/Dockerfile @@ -0,0 +1,154 @@ +FROM python:3.7-stretch + +LABEL maintainer="Sebastian Ramirez " + +# Standard set up Nginx +ENV NGINX_VERSION 1.13.12-1~stretch +ENV NJS_VERSION 1.13.12.0.2.0-1~stretch + +RUN set -x \ + && apt-get update \ + && apt-get install --no-install-recommends --no-install-suggests -y gnupg1 apt-transport-https ca-certificates \ + && \ + NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \ + found=''; \ + for server in \ + ha.pool.sks-keyservers.net \ + hkp://keyserver.ubuntu.com:80 \ + hkp://p80.pool.sks-keyservers.net:80 \ + pgp.mit.edu \ + ; do \ + echo "Fetching GPG key $NGINX_GPGKEY from $server"; \ + apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \ + done; \ + test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \ + apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/* \ + && dpkgArch="$(dpkg --print-architecture)" \ + && nginxPackages=" \ + nginx=${NGINX_VERSION} \ + nginx-module-xslt=${NGINX_VERSION} \ + nginx-module-geoip=${NGINX_VERSION} \ + nginx-module-image-filter=${NGINX_VERSION} \ + nginx-module-njs=${NJS_VERSION} \ + " \ + && case "$dpkgArch" in \ + amd64|i386) \ +# arches officialy built by upstream + echo "deb https://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list.d/nginx.list \ + && apt-get update \ + ;; \ + *) \ +# we're on an architecture upstream doesn't officially build for +# let's build binaries from the published source packages + echo "deb-src https://nginx.org/packages/mainline/debian/ stretch nginx" >> /etc/apt/sources.list.d/nginx.list \ + \ +# new directory for storing sources and .deb files + && tempDir="$(mktemp -d)" \ + && chmod 777 "$tempDir" \ +# (777 to ensure APT's "_apt" user can access it too) + \ +# save list of currently-installed packages so build dependencies can be cleanly removed later + && savedAptMark="$(apt-mark showmanual)" \ + \ +# build .deb files from upstream's source packages (which are verified by apt-get) + && apt-get update \ + && apt-get build-dep -y $nginxPackages \ + && ( \ + cd "$tempDir" \ + && DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \ + apt-get source --compile $nginxPackages \ + ) \ +# we don't remove APT lists here because they get re-downloaded and removed later + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies +# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies) + && apt-mark showmanual | xargs apt-mark auto > /dev/null \ + && { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \ + \ +# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be) + && ls -lAFh "$tempDir" \ + && ( cd "$tempDir" && dpkg-scanpackages . > Packages ) \ + && grep '^Package: ' "$tempDir/Packages" \ + && echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list \ +# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes") +# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied) +# ... +# E: Failed to fetch store:/var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied) + && apt-get -o Acquire::GzipIndexes=false update \ + ;; \ + esac \ + \ + && apt-get install --no-install-recommends --no-install-suggests -y \ + $nginxPackages \ + gettext-base \ + && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx.list \ + \ +# if we have leftovers from building, let's purge them (including extra, unnecessary build deps) + && if [ -n "$tempDir" ]; then \ + apt-get purge -y --auto-remove \ + && rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \ + fi + +# forward request and error logs to docker log collector +RUN ln -sf /dev/stdout /var/log/nginx/access.log \ + && ln -sf /dev/stderr /var/log/nginx/error.log +EXPOSE 80 +# Removed the section that breaks pip installations +# && apt-get remove --purge --auto-remove -y apt-transport-https ca-certificates +# Standard set up Nginx finished + +# Expose 443, in case of LTS / HTTPS +EXPOSE 443 + +# Install uWSGI +RUN pip install uwsgi + +# Make NGINX run on the foreground +RUN echo "daemon off;" >> /etc/nginx/nginx.conf +# Remove default configuration from Nginx +RUN rm /etc/nginx/conf.d/default.conf +# Copy the modified Nginx conf +COPY nginx.conf /etc/nginx/conf.d/ +# Copy the base uWSGI ini file to enable default dynamic uwsgi process number +COPY uwsgi.ini /etc/uwsgi/ + +# Install Supervisord +RUN apt-get update && apt-get install -y supervisor \ +&& rm -rf /var/lib/apt/lists/* +# Custom Supervisord config +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# Which uWSGI .ini file should be used, to make it customizable +ENV UWSGI_INI /app/uwsgi.ini + +# By default, run 2 processes +ENV UWSGI_CHEAPER 2 + +# By default, when on demand, run up to 16 processes +ENV UWSGI_PROCESSES 16 + +# By default, allow unlimited file sizes, modify it to limit the file sizes +# To have a maximum of 1 MB (Nginx's default) change the line to: +# ENV NGINX_MAX_UPLOAD 1m +ENV NGINX_MAX_UPLOAD 0 + +# By default, Nginx will run a single worker process, setting it to auto +# will create a worker for each CPU core +ENV NGINX_WORKER_PROCESSES 1 + +# By default, Nginx listens on port 80. +# To modify this, change LISTEN_PORT environment variable. +# (in a Dockerfile or with an option for `docker run`) +ENV LISTEN_PORT 80 + +# Copy the entrypoint that will generate Nginx additional configs +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] + +# Add demo app +COPY ./app /app +WORKDIR /app + +CMD ["/usr/bin/supervisord"] diff --git a/python3.7/app/main.py b/python3.7/app/main.py new file mode 100644 index 0000000..216c258 --- /dev/null +++ b/python3.7/app/main.py @@ -0,0 +1,4 @@ +def application(env, start_response): + start_response('200 OK', [('Content-Type', 'text/html')]) + return [b"Hello World from a default Nginx uWSGI Python 3.6 app in a\ + Docker container (default)"] diff --git a/python3.7/app/uwsgi.ini b/python3.7/app/uwsgi.ini new file mode 100644 index 0000000..8a29f73 --- /dev/null +++ b/python3.7/app/uwsgi.ini @@ -0,0 +1,2 @@ +[uwsgi] +wsgi-file=/app/main.py diff --git a/python3.7/entrypoint.sh b/python3.7/entrypoint.sh new file mode 100644 index 0000000..fc1ddaf --- /dev/null +++ b/python3.7/entrypoint.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -e + +# Get the maximum upload file size for Nginx, default to 0: unlimited +USE_NGINX_MAX_UPLOAD=${NGINX_MAX_UPLOAD:-0} +# Generate Nginx config for maximum upload file size +echo "client_max_body_size $USE_NGINX_MAX_UPLOAD;" > /etc/nginx/conf.d/upload.conf + +# Get the number of workers for Nginx, default to 1 +USE_NGINX_WORKER_PROCESSES=${NGINX_WORKER_PROCESSES:-1} +# Modify the number of worker processes in Nginx config +sed -i "/worker_processes\s/c\worker_processes ${USE_NGINX_WORKER_PROCESSES};" /etc/nginx/nginx.conf + +# Set the max number of connections per worker for Nginx, if requested +# Cannot exceed worker_rlimit_nofile, see NGINX_WORKER_OPEN_FILES below +if [[ -v NGINX_WORKER_CONNECTIONS ]] ; then + sed -i "/worker_connections\s/c\ worker_connections ${NGINX_WORKER_CONNECTIONS};" /etc/nginx/nginx.conf +fi + +# Set the max number of open file descriptors for Nginx workers, if requested +if [[ -v NGINX_WORKER_OPEN_FILES ]] ; then + echo "worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES};" >> /etc/nginx/nginx.conf +fi + +# Get the listen port for Nginx, default to 80 +USE_LISTEN_PORT=${LISTEN_PORT:-80} +# Modify Nignx config for listen port +if ! grep -q "listen ${USE_LISTEN_PORT};" /etc/nginx/conf.d/nginx.conf ; then + sed -i -e "/server {/a\ listen ${USE_LISTEN_PORT};" /etc/nginx/conf.d/nginx.conf +fi +exec "$@" diff --git a/python3.7/nginx.conf b/python3.7/nginx.conf new file mode 100644 index 0000000..eca3646 --- /dev/null +++ b/python3.7/nginx.conf @@ -0,0 +1,6 @@ +server { + location / { + include uwsgi_params; + uwsgi_pass unix:///tmp/uwsgi.sock; + } +} \ No newline at end of file diff --git a/python3.7/supervisord.conf b/python3.7/supervisord.conf new file mode 100644 index 0000000..96f5b72 --- /dev/null +++ b/python3.7/supervisord.conf @@ -0,0 +1,18 @@ +[supervisord] +nodaemon=true + +[program:uwsgi] +command=/usr/local/bin/uwsgi --ini /etc/uwsgi/uwsgi.ini --die-on-term --need-app +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 diff --git a/python3.7/uwsgi.ini b/python3.7/uwsgi.ini new file mode 100644 index 0000000..93ce92f --- /dev/null +++ b/python3.7/uwsgi.ini @@ -0,0 +1,7 @@ +[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 \ No newline at end of file