diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml index b6a62c9..6d1454a 100644 --- a/.github/workflows/dockerimage.yml +++ b/.github/workflows/dockerimage.yml @@ -1,50 +1,74 @@ # gokaygurcan/dockerfile-nginx -name: 'NGINX' +name: nginx on: push: pull_request: branches: - - master + - main env: GITHUB: ${{ toJson(github) }} jobs: + version: + name: Version + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - id: version + name: Version + run: | + grep -r "NGINX_VERSION=" Dockerfile | cut -d "=" -f 2 | cut -d " " -f 1 + echo "::set-output name=version::$(grep -r "NGINX_VERSION=" Dockerfile | cut -d "=" -f 2 | cut -d " " -f 1)" + nginx: - name: 'nginx' - runs-on: 'ubuntu-latest' + name: nginx + runs-on: ubuntu-latest env: CI: true steps: - - id: 'checkout' - name: 'Checkout' - uses: 'actions/checkout@v2' - - - id: 'login' - name: 'Login to Docker Hub' - uses: 'actions-hub/docker/login@master' - if: github.ref == 'refs/heads/master' - env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - - - id: 'build' - name: 'Build image' + - id: sanity-check + name: Sanity check + run: | + printenv + + - id: checkout + name: Checkout + uses: actions/checkout@v3 + + - id: login + name: Login to Docker Hub + uses: docker/login-action@v2 + if: | + github.ref == 'refs/heads/main' + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - id: build + name: Build image run: | - docker build --file Dockerfile --tag gokaygurcan/nginx:latest . + docker build --file Dockerfile --tag gokaygurcan/nginx:latest --tag gokaygurcan/nginx:${{ steps.version.outputs.version }} . + docker ps -a - - id: 'test' - name: 'Test' + - id: test + name: Test run: | docker volume create usr-share-geoip docker run --rm --name geoipupdate -v usr-share-geoip:/usr/share/GeoIP -e GEOIPUPDATE_FREQUENCY=0 -e GEOIPUPDATE_ACCOUNT_ID='${{ secrets.GEOIPUPDATE_ACCOUNT_ID }}' -e GEOIPUPDATE_LICENSE_KEY='${{ secrets.GEOIPUPDATE_LICENSE_KEY }}' -e GEOIPUPDATE_EDITION_IDS='GeoLite2-City GeoLite2-Country' maxmindinc/geoipupdate docker run --rm --name nginx gokaygurcan/nginx nginx -V - - id: 'push' - name: 'Push to Docker Registry' - uses: 'actions-hub/docker@master' - if: github.ref == 'refs/heads/master' + - id: push + name: Push to Docker Registry + uses: docker/build-push-action@v3 + if: | + github.ref == 'refs/heads/main' with: - args: push gokaygurcan/nginx:latest + context: . + push: true + tags: | + gokaygurcan/nginx:latest + gokaygurcan/nginx:${{ steps.version.outputs.version }} diff --git a/Dockerfile b/Dockerfile index e9867df..c4e7c82 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,10 +9,10 @@ ENV DEBIAN_FRONTEND="noninteractive" \ USR_SRC=/usr/src \ USR_SRC_NGINX=/usr/src/nginx \ USR_SRC_NGINX_MODS=/usr/src/nginx/modules \ - NGINX_VERSION=1.22.0 \ - OPENSSL_VERSION=1.1.1p \ + NGINX_VERSION=1.25.3 \ + OPENSSL_VERSION=1.1.1w \ PAGESPEED_VERSION=1.13.35.2 \ - LIBMAXMINDDB_VERSION=1.6.0 + LIBMAXMINDDB_VERSION=1.8.0 USER root @@ -30,9 +30,11 @@ RUN set -ex && \ libmaxminddb-dev \ libpcre3 \ libpcre3-dev \ + libxml2 \ + libxml2-dev \ + libxslt1-dev \ mmdb-bin \ uuid-dev \ - zlibc \ zlib1g \ zlib1g-dev && \ # maxmind geoip2 @@ -116,9 +118,11 @@ RUN set -ex && \ wget -q https://dl.google.com/dl/page-speed/psol/${PAGESPEED_VERSION}-x64.tar.gz && \ tar -xzf ${PAGESPEED_VERSION}-x64.tar.gz && \ rm ${PAGESPEED_VERSION}-x64.tar.gz && \ - mkdir -p /var/cache/ngx_pagespeed && \ + mkdir -p /var/cache/ngx_pagespeed + + # && \ # compile nginx - cd ${USR_SRC_NGINX} && \ +RUN cd ${USR_SRC_NGINX} && \ sh ./configure \ --conf-path=/etc/nginx/nginx.conf \ --sbin-path=/usr/sbin/nginx \ @@ -143,7 +147,6 @@ RUN set -ex && \ --with-http_stub_status_module \ --with-http_sub_module \ --with-http_v2_module \ - --with-ipv6 \ --with-openssl=${USR_SRC_NGINX_MODS}/openssl \ --with-compat \ --with-mail \ @@ -165,6 +168,7 @@ RUN set -ex && \ --add-module=${USR_SRC_NGINX_MODS}/sysguard \ --add-module=${USR_SRC_NGINX_MODS}/brotli \ --add-module=${USR_SRC_NGINX_MODS}/fancyindex && \ + # make and install make && \ make install && \ echo "✓" | tee /usr/local/nginx/html/index.html && \ @@ -175,10 +179,9 @@ RUN set -ex && \ rm -rf ${USR_SRC_NGINX} && \ rm -rf /var/lib/{apt,dpkg,cache,log}/ && \ rm -rf /var/tmp/* && \ - rm -rf /tmp/* - -# forward request and error logs to docker log collector -RUN ln -sf /dev/stdout /var/log/nginx/access.log && \ + rm -rf /tmp/* && \ + # 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 WORKDIR /etc/nginx diff --git a/README.md b/README.md index 58c8efa..3ce764f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # NGINX -![Deploy to Docker Hub](https://github.com/gokaygurcan/dockerfile-nginx/workflows/Deploy%20to%20Docker%20Hub/badge.svg?branch=master) - -

Environment variables

+## Environment variables | Variable | Path | | -------------------- | ---------------------- | @@ -17,18 +15,21 @@ | PAGESPEED_VERSION | 1.13.35.2 | | LIBMAXMINDDB_VERSION | 1.6.0 | -

Additional packages

+## Additional packages - libbrotli-dev +- libmaxminddb-dev - libpcre3 - libpcre3-dev +- libxml2 +- libxml2-dev +- libxslt1-dev - mmdb-bin - uuid-dev -- zlibc - zlib1g - zlib1g-dev -

Volumes

+## Volumes | Path | Description | | ---------------- | -------------------------------------------------------------------------------------- | @@ -38,20 +39,20 @@ | /etc/letsencrypt | Let's Encrypt files (see [certbot](https://github.com/gokaygurcan/dockerfile-certbot)) | | /usr/share/GeoIP | GeoIP database folder (see below) | -

Ports

+## Ports | Port | Process | TCP/UDP | | ---- | ------- | ------- | | 80 | NGINX | TCP | | 443 | NGINX | TCP | -

CMD

+## CMD ```bash sudo nginx -g daemon off; ``` -

Usage

+## Usage To pull the image @@ -77,7 +78,7 @@ docker run --rm -d --name nginx -p 80:80 -p 443:443 \ curl -i http://localhost ``` -

GeoIP

+## GeoIP To use GeoIP, you need to download City and/or Country databases from MaxMind. The best way to do it is to use their Docker container.