-
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Alpine Linux 3.9 images
- Loading branch information
Showing
31 changed files
with
979 additions
and
1 deletion.
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
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
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,194 @@ | ||
FROM python:2.7-alpine3.9 | ||
|
||
LABEL maintainer="Sebastian Ramirez <tiangolo@gmail.com>" | ||
|
||
# Standard set up Nginx Alpine | ||
# https://github.com/nginxinc/docker-nginx/blob/f3fc4d5753f0ebb9107738183b9c5cea1bf3f618/mainline/alpine/Dockerfile | ||
|
||
ENV NGINX_VERSION 1.15.3 | ||
|
||
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 \ | ||
gnupg1 \ | ||
libxslt-dev \ | ||
gd-dev \ | ||
geoip-dev \ | ||
&& curl -fSL https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tar.gz \ | ||
&& curl -fSL https://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 -rf "$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 | ||
|
||
# Standard set up Nginx finished | ||
|
||
EXPOSE 80 | ||
|
||
|
||
# # Expose 443, in case of LTS / HTTPS | ||
EXPOSE 443 | ||
|
||
# Install uWSGI | ||
RUN apk add --no-cache uwsgi-python | ||
|
||
# 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"] |
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 in Alpine (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,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,65 @@ | ||
#!/usr/bin/env sh | ||
set -e | ||
|
||
# Explicitly add installed Python packages and uWSGI Python packages to PYTHONPATH | ||
# Otherwise uWSGI can't import Flask | ||
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages | ||
|
||
# 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,18 @@ | ||
[supervisord] | ||
nodaemon=true | ||
|
||
[program:uwsgi] | ||
command=/usr/sbin/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,11 @@ | ||
[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 | ||
plugin = python | ||
# For debugging and testing | ||
show-config = true |
Oops, something went wrong.