Skip to content

Commit

Permalink
here be lions
Browse files Browse the repository at this point in the history
  • Loading branch information
wokalek committed Jul 26, 2023
0 parents commit 357798e
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 0 deletions.
96 changes: 96 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
ARG ALPINE_VERSION=3.18.2
ARG NGINX_VERSION=1.25.1
ARG PCRE2_VERSION=10.42
ARG BROTLI_COMMIT=6e975bcb015f62e1f303054897783355e2a877dc

FROM alpine:$ALPINE_VERSION AS build

ARG NGINX_VERSION
ARG PCRE2_VERSION
ARG BROTLI_COMMIT

WORKDIR /src

RUN \
# Dependencies
apk add --no-cache git make gcc openssl-dev zlib-dev linux-headers g++ && \
# Brotli
mkdir ngx_brotli && \
cd ngx_brotli && \
git init && \
git remote add origin https://github.com/google/ngx_brotli.git && \
git fetch --depth 1 origin $BROTLI_COMMIT && \
git checkout FETCH_HEAD && \
git submodule update --init --recursive --depth 1 && \
cd .. && \
# PCRE2
wget -O - https://github.com/PCRE2Project/pcre2/releases/download/pcre2-$PCRE2_VERSION/pcre2-$PCRE2_VERSION.tar.gz | tar xz && \
# Nginx
wget -O - https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz | tar xz && \
# Nginx build
cd nginx-$NGINX_VERSION && \
./configure \
--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-compat \
--with-file-aio \
--with-threads \
--with-http_addition_module \
--with-http_auth_request_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_realip_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_sub_module \
--with-http_v2_module \
--with-http_v3_module \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_realip_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-pcre=/src/pcre2-$PCRE2_VERSION \
--with-pcre-jit \
--add-module=/src/ngx_brotli && \
make && \
make install

FROM alpine:$ALPINE_VERSION

COPY --from=build /usr/sbin/nginx /usr/sbin
COPY --from=build /etc/nginx /etc/nginx

RUN \
addgroup -S nginx \
&& adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \
&& adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G users -u 1000 user \
&& mkdir /var/log/nginx && touch /var/log/nginx/access.log /var/log/nginx/error.log \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log

EXPOSE 80 443

STOPSIGNAL SIGTERM

CMD ["nginx", "-g", "daemon off;"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Alexandr Wokalek

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## About

This is a super simple and easy to read nginx docker alpine-based image.

## What's inside

- Only default [nginx modules](https://nginx.org/en/docs/)
- [`ngx_brotli`](https://github.com/google/ngx_brotli) - brotli algorithm compression
- Ports `80` and `443` are exposed by default

## Why?

This is the smallest and most up-to-date nginx-brotli image you can find.

The most popular `fholzer/nginx-brotli` with 1 million pools is 13.96 MB, `wokalek/nginx-brotli` is **9.36 MB** (compressed size, compare 1.25.1 tags).

Alpine! Everyone loves alpine. Other images you may find use different base images.

And of course this dockerfile can be perfect for your nginx build with your modules! Take a look.

## How to use this image

You can use this image just like the [official nginx](https://hub.docker.com/_/nginx).

Check out the available tags.

0 comments on commit 357798e

Please sign in to comment.