Skip to content

Commit

Permalink
breaking: update nginx version
Browse files Browse the repository at this point in the history
Signed-off-by: Gökay Gürcan <[email protected]>
  • Loading branch information
gokaygurcan committed Jan 7, 2024
1 parent 85c33ef commit 95f8d5b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 47 deletions.
76 changes: 50 additions & 26 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
@@ -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 }}
25 changes: 14 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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 \
Expand All @@ -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 \
Expand All @@ -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 && \
Expand All @@ -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
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# NGINX

![Deploy to Docker Hub](https://github.com/gokaygurcan/dockerfile-nginx/workflows/Deploy%20to%20Docker%20Hub/badge.svg?branch=master)

<h2>Environment variables</h2>
## Environment variables

| Variable | Path |
| -------------------- | ---------------------- |
Expand All @@ -17,18 +15,21 @@
| PAGESPEED_VERSION | 1.13.35.2 |
| LIBMAXMINDDB_VERSION | 1.6.0 |

<h2>Additional packages</h2>
## Additional packages

- libbrotli-dev
- libmaxminddb-dev
- libpcre3
- libpcre3-dev
- libxml2
- libxml2-dev
- libxslt1-dev
- mmdb-bin
- uuid-dev
- zlibc
- zlib1g
- zlib1g-dev

<h2>Volumes</h2>
## Volumes

| Path | Description |
| ---------------- | -------------------------------------------------------------------------------------- |
Expand All @@ -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) |

<h2>Ports</h2>
## Ports

| Port | Process | TCP/UDP |
| ---- | ------- | ------- |
| 80 | NGINX | TCP |
| 443 | NGINX | TCP |

<h2>CMD</h2>
## CMD

```bash
sudo nginx -g daemon off;
```

<h2>Usage</h2>
## Usage

To pull the image

Expand All @@ -77,7 +78,7 @@ docker run --rm -d --name nginx -p 80:80 -p 443:443 \
curl -i http://localhost
```

<h2>GeoIP</h2>
## 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.

Expand Down

0 comments on commit 95f8d5b

Please sign in to comment.