├── docker-nginx-reload.sh ├── docker-entrypoint.sh ├── Dockerfile ├── .github └── workflows │ └── dockerimage.yml ├── docker-nginx-update.sh ├── README.md └── LICENSE /docker-nginx-reload.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -e 4 | 5 | docker-nginx-update.sh 6 | 7 | nginx -s reload 8 | -------------------------------------------------------------------------------- /docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -e 4 | 5 | destdir="/etc/nginx" 6 | workdir="/usr/src/docker-nginx" 7 | defaults="$workdir/defaults" 8 | cachedir="/var/cache/nginx" 9 | 10 | mkdir -p "$workdir" "$cachedir" 11 | mv "$destdir" "$defaults" 12 | chown -R www-data:www-data "$cachedir" 13 | chmod -R o-rwx "$cachedir" 14 | 15 | docker-nginx-update.sh 16 | 17 | exec "$@" 18 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:bullseye-slim 2 | 3 | ARG VERSION="1.21.4-1sb+300+11bullseye1" 4 | ARG PACKAGE_REPO="https://mirror.xtom.com/sb/nginx" 5 | 6 | RUN set -ex; \ 7 | apt-get update; \ 8 | apt-get install -y --no-install-recommends ca-certificates gettext-base wget; \ 9 | wget -O /etc/apt/trusted.gpg.d/sb-nginx.asc "$PACKAGE_REPO/public.key"; \ 10 | echo "deb $PACKAGE_REPO bullseye main" > /etc/apt/sources.list.d/sb-nginx.list; \ 11 | apt-get update; \ 12 | apt-get install -y --no-install-recommends "nginx=$VERSION"; \ 13 | apt-get purge -y --auto-remove wget; \ 14 | rm -rf /var/lib/apt/lists/*; \ 15 | ln -sf /dev/stdout /var/log/nginx/access.log; \ 16 | ln -sf /dev/stderr /var/log/nginx/error.log 17 | 18 | COPY docker-nginx-*.sh docker-entrypoint.sh /usr/local/bin/ 19 | 20 | ENTRYPOINT ["docker-entrypoint.sh"] 21 | 22 | CMD ["nginx", "-g", "daemon off;"] 23 | -------------------------------------------------------------------------------- /.github/workflows/dockerimage.yml: -------------------------------------------------------------------------------- 1 | name: Docker Image CI 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*" 7 | 8 | env: 9 | DOCKER_HUB_USERNAME: bohan 10 | DOCKER_IMAGE_REPO: bohan/sb-nginx 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v1 17 | - name: Login 18 | run: docker login -u "$DOCKER_HUB_USERNAME" -p "${{ secrets.DOCKER_HUB_PASSWORD }}" 19 | - name: Build the Docker image 20 | run: docker build . --file Dockerfile --tag "$DOCKER_IMAGE_REPO:latest" 21 | - name: Test 22 | run: docker run --rm "$DOCKER_IMAGE_REPO:latest" sh -c "nginx -V && nginx -t" 23 | - name: Tag 24 | run: docker tag "$DOCKER_IMAGE_REPO:latest" "$DOCKER_IMAGE_REPO:${GITHUB_REF##*/v}" 25 | - name: Push 26 | run: | 27 | docker push "$DOCKER_IMAGE_REPO:${GITHUB_REF##*/v}"; 28 | docker push "$DOCKER_IMAGE_REPO:latest" 29 | -------------------------------------------------------------------------------- /docker-nginx-update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -e 4 | 5 | test_exists_one() 6 | { 7 | test -e "$1" 8 | } 9 | 10 | destdir="/etc/nginx" 11 | 12 | # First Start: "/etc/nginx" 13 | # Subsequent Updates: "/usr/src/docker-nginx/v0000000000000000000" 14 | currdir="$(readlink -f $destdir)" 15 | 16 | workdir="/usr/src/docker-nginx" 17 | confdir="$workdir/conf" 18 | defaults="$workdir/defaults" 19 | 20 | # First Start: "/usr/src/docker-nginx/v0000000000000000000" 21 | # Subsequent Updates: "/usr/src/docker-nginx/v1111111111111111111" 22 | nextdir="$workdir/v$(date +%s%N)" 23 | 24 | rm -rf "$nextdir" 25 | mkdir "$nextdir" 26 | 27 | mkdir -p "$confdir" 28 | cp -R "$defaults/"* "$nextdir" 29 | 30 | if test_exists_one "$confdir/"*; then 31 | cp -R "$confdir/"* "$nextdir" 32 | fi 33 | 34 | ln -sfn "$nextdir" "$destdir" 35 | 36 | if nginx -t; then 37 | if [ "$currdir" != "$destdir" ]; then 38 | rm -rf "$currdir" 39 | fi 40 | else 41 | if [ "$currdir" != "$destdir" ]; then 42 | ln -sfn "$currdir" "$destdir" 43 | fi 44 | rm -rf "$nextdir" 45 | exit 1 46 | fi 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker image for [nginx.io](https://nginx.io/) 2 | 3 | [![](https://dockeri.co/image/bohan/sb-nginx)](https://hub.docker.com/r/bohan/sb-nginx) 4 | 5 | [nginx.io](https://nginx.io/) (sb-nginx) is a Debian package by [SB Professional Services](https://www.sb/) / [xTom](https://xtom.com/) offering a nginx build supports: 6 | 7 | * Brotli compression 8 | * OpenSSL 3.0.0 with TLS 1.3 support 9 | * GeoIP2 10 | 11 | ## **Awesome** Usage 12 | 13 | Put your config files (`nginx.conf` etc.) inside a folder, for example: `~/nginx-config`. 14 | 15 | Then `run` the container: 16 | 17 | docker run --name nginx --net host --restart always -v $HOME/nginx-config:/usr/src/docker-nginx/conf:ro -d bohan/sb-nginx 18 | 19 | You **must** mount the config dir to this specific `/usr/src/docker-nginx/conf` path! 20 | 21 | Your existing config files will **replace** default config files. 22 | 23 | ### Reload Changed Configuration 24 | 25 | You can even change your configuration after the container start and apply them without any downtime. 26 | 27 | After change, run the command: 28 | 29 | docker exec nginx docker-nginx-reload.sh 30 | 31 | This `docker-nginx-reload.sh` script will test your new configuration and reload the server. It will rollback if the test fails. 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | --------------------------------------------------------------------------------