├── LICENSE ├── README.md ├── assets └── logo.png ├── src ├── .env ├── Dockerfile.alpine └── Dockerfile.debian └── update.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Nginx with Docker, soulteary 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nginx Docker Playground 2 | 3 | 4 | 5 | Nginx Development Environment based on official docker image and official source code. 6 | 7 | ## Quick Start 8 | 9 | ```bash 10 | docker pull soulteary/prebuilt-nginx-modules:base-1.24.0 11 | # or 12 | docker pull soulteary/prebuilt-nginx-modules:base-1.23.1-alpine 13 | ``` 14 | 15 | Example, how to quickly build a nginx addon: 16 | 17 | ```docker 18 | # @see https://github.com/nginx-with-docker/ngx_http_srcache_filter_module/blob/main/docker/0.32/Dockerfile.alpine 19 | 20 | ARG NGINX_VERSION=1.19.7 21 | FROM soulteary/prebuilt-nginx-modules:base-${NGINX_VERSION}-alpine AS Builder 22 | 23 | ARG MODULE_CHECKSUM=127181f371046cc5ec0e0acf1b45cd478a8a7a5f 24 | ARG MODULE_VERSION=0.32 25 | ARG MODULE_NAME=srcache-nginx-module-src 26 | ARG MODULE_SOURCE=https://github.com/nginx-with-docker/srcache-nginx-module-src 27 | 28 | RUN cd /usr/src && \ 29 | curl -L "${MODULE_SOURCE}/archive/refs/tags/v${MODULE_VERSION}.tar.gz" -o "${MODULE_VERSION}.tar.gz" && \ 30 | echo "${MODULE_CHECKSUM} ${MODULE_VERSION}.tar.gz" | shasum -c && \ 31 | tar -zxC /usr/src -f ${MODULE_VERSION}.tar.gz && \ 32 | cd /usr/src && \ 33 | mv ${MODULE_NAME}-${MODULE_VERSION}/ ${MODULE_NAME} && \ 34 | cd /usr/src/nginx && \ 35 | CONFARGS=$(nginx -V 2>&1 | sed -n -e 's/^.*arguments: //p') \ 36 | CONFARGS=${CONFARGS/-Os -fomit-frame-pointer -g/-Os} && \ 37 | echo $CONFARGS && \ 38 | ./configure --with-compat $CONFARGS --add-dynamic-module=../${MODULE_NAME}/ && \ 39 | make modules 40 | 41 | FROM scratch 42 | 43 | COPY --from=Builder /usr/src/nginx/objs/ngx_http_srcache_filter_module.so / 44 | ``` 45 | 46 | ## Pre-built Nginx Addons 47 | 48 | Pre-built nginx addons binaries based on this project 49 | - https://github.com/nginx-with-docker/prebuilt-nginx-modules 50 | 51 | ## Support Nginx Versions 52 | 53 | Below are other available nginx versions. 54 | 55 | - 1.24.0 56 | - 1.23.1 57 | - 1.23.0 58 | - 1.22.0 59 | - 1.21.6 60 | - 1.21.5 61 | - 1.21.4 62 | - 1.21.3 63 | - 1.21.1 64 | - 1.21.0 65 | - 1.20.0 66 | - 1.19.10 67 | - 1.19.9 68 | - 1.19.8 69 | - 1.19.7 70 | -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nginx-with-docker/nginx-docker-playground/30a8542c4338c12d366d82a779b3c3a350a333d9/assets/logo.png -------------------------------------------------------------------------------- /src/.env: -------------------------------------------------------------------------------- 1 | NGINX_VERSION=1.24.0 2 | NGINX_SHASUM=fec561c95c0320f1860c0d55a8724cd45e5cc238 -------------------------------------------------------------------------------- /src/Dockerfile.alpine: -------------------------------------------------------------------------------- 1 | ARG NGINX_VERSION=1.19.7 2 | FROM nginx:${NGINX_VERSION}-alpine 3 | # Mirror 4 | # RUN cat /etc/apk/repositories | sed -e "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/" | tee /etc/apk/repositories 5 | 6 | ARG NGINX_SHASUM=0dde53b5a948efc9dc852814186052e559d190ea 7 | RUN apk add --no-cache --virtual .build-deps gcc libc-dev make openssl-dev pcre2-dev zlib-dev linux-headers libxslt-dev gd-dev geoip-dev perl-dev libedit-dev mercurial bash alpine-sdk findutils && \ 8 | mkdir -p /usr/src && cd /usr/src && \ 9 | curl -L "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -o nginx.tar.gz && \ 10 | echo "$NGINX_SHASUM nginx.tar.gz" | shasum -c && \ 11 | tar -zxC /usr/src -f nginx.tar.gz && \ 12 | cd /usr/src && \ 13 | mv /usr/src/nginx-$NGINX_VERSION /usr/src/nginx && \ 14 | CONFARGS=$(nginx -V 2>&1 | sed -n -e 's/^.*arguments: //p') \ 15 | CONFARGS=${CONFARGS/-Os -fomit-frame-pointer -g/-Os} && \ 16 | export CONFARGS=$CONFARGS; -------------------------------------------------------------------------------- /src/Dockerfile.debian: -------------------------------------------------------------------------------- 1 | # https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#sources 2 | 3 | ARG NGINX_VERSION=1.19.7 4 | FROM nginx:${NGINX_VERSION} 5 | # Mirror 6 | # RUN sed -i 's/http:\/\/.*.debian.org/https:\/\/mirrors.tuna.tsinghua.edu.cn\/debian\/dists\/Debian10.10/' /etc/apt/sources.list 7 | 8 | ARG NGINX_SHASUM=0dde53b5a948efc9dc852814186052e559d190ea 9 | 10 | RUN apt-get update && \ 11 | apt-get install -y apt-transport-https lsb-release ca-certificates && \ 12 | apt-get install -y build-essential software-properties-common && \ 13 | apt install -y perl libperl-dev libgd3 libgd-dev libgeoip1 libgeoip-dev geoip-bin libxml2 libxml2-dev libxslt1.1 libxslt1-dev libc6-dev libpcre3-dev&& \ 14 | apt install -y wget curl && mkdir -p /usr/src 15 | 16 | RUN cd /usr/src && \ 17 | wget https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.gz && \ 18 | tar zxvf pcre2-10.42.tar.gz && \ 19 | cd pcre2-10.42 && \ 20 | ./configure && make && make install 21 | 22 | RUN cd /usr/src && \ 23 | wget https://www.zlib.net/zlib-1.2.13.tar.gz && \ 24 | tar zxvf zlib-1.2.13.tar.gz && \ 25 | cd zlib-1.2.13 && \ 26 | ./configure && make && make install 27 | 28 | RUN cd /usr/src && \ 29 | wget http://www.openssl.org/source/openssl-1.1.1t.tar.gz && \ 30 | tar zxvf openssl-1.1.1t.tar.gz && \ 31 | cd openssl-1.1.1t && \ 32 | ./config && make && make install 33 | 34 | RUN cd /usr/src && \ 35 | curl -L "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -o nginx.tar.gz && \ 36 | echo "$NGINX_SHASUM nginx.tar.gz" | shasum -c && \ 37 | tar -zxC /usr/src -f nginx.tar.gz && \ 38 | cd /usr/src && \ 39 | mv /usr/src/nginx-$NGINX_VERSION /usr/src/nginx && \ 40 | CONFARGS=$(nginx -V 2>&1 | sed -n -e 's/^.*arguments: //p' | sed -n -e 's/--with-cc-opt=.*//p') && \ 41 | echo "CONFARGS=\"$CONFARGS\"" >>~/.bashrc && echo "export CONFARGS" >>~/.bashrc 42 | 43 | SHELL ["/bin/bash", "-c"] 44 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | RELEASE_DIR="./src"; 4 | REPO_NAME="soulteary/prebuilt-nginx-modules" 5 | 6 | set -a 7 | . "$RELEASE_DIR/.env" 8 | set +a 9 | 10 | # Build For Alpine 11 | 12 | TAG=base-$NGINX_VERSION-alpine; 13 | DIST=$REPO_NAME:$TAG 14 | 15 | echo "Build: $DIST"; 16 | 17 | echo $NGINX_VERSION:$NGINX_SHASUM 18 | echo "docker build --build-arg NGINX_VERSION=$NGINX_VERSION --build-arg NGINX_SHASUM=$NGINX_SHASUM --tag $DIST -f "$RELEASE_DIR/Dockerfile.alpine" ." 19 | docker build --build-arg NGINX_VERSION="$NGINX_VERSION" --build-arg NGINX_SHASUM="$NGINX_SHASUM" --tag $DIST -f "$RELEASE_DIR/Dockerfile.alpine" . 20 | 21 | if [[ "$(docker images -q $DIST 2> /dev/null)" != "" ]]; then 22 | echo "Push: $DIST"; 23 | docker push $DIST; 24 | fi 25 | 26 | 27 | 28 | # Build For Debian 29 | 30 | TAG=base-$NGINX_VERSION; 31 | DIST=$REPO_NAME:$TAG 32 | 33 | echo "Build: $DIST"; 34 | 35 | echo $NGINX_VERSION:$NGINX_SHASUM 36 | echo "docker build --build-arg NGINX_VERSION=$NGINX_VERSION --build-arg NGINX_SHASUM=$NGINX_SHASUM --tag $DIST -f "$RELEASE_DIR/Dockerfile.debian" ." 37 | docker build --build-arg NGINX_VERSION="$NGINX_VERSION" --build-arg NGINX_SHASUM="$NGINX_SHASUM" --tag $DIST -f "$RELEASE_DIR/Dockerfile.debian" . 38 | 39 | if [[ "$(docker images -q $DIST 2> /dev/null)" != "" ]]; then 40 | echo "Push: $DIST"; 41 | docker push $DIST; 42 | fi 43 | --------------------------------------------------------------------------------