mirror of
https://github.com/dokku/buildpack-nginx.git
synced 2026-04-24 01:27:37 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0fcbc35eed | |||
| cad1e54b14 | |||
| df8cba3582 | |||
| aaf995fd4e | |||
| ec95819e3d | |||
| 11755954fe | |||
| d72ac92402 | |||
| 27155d8eaf | |||
| d157f257ce | |||
| a0f7d9e34f |
68
.github/workflows/ci.yml
vendored
Normal file
68
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
---
|
||||||
|
name: "ci"
|
||||||
|
|
||||||
|
# yamllint disable-line rule:truthy
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- main
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
if: github.event_name != 'release'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Run shellcheck
|
||||||
|
run: make test
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Download source tarballs
|
||||||
|
run: |
|
||||||
|
source "$GITHUB_WORKSPACE/conf/nginx-configure-flags"
|
||||||
|
cd /tmp
|
||||||
|
curl -sSL "https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" | tar xz
|
||||||
|
curl -sSL "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-${PCRE_VERSION}/pcre2-${PCRE_VERSION}.tar.gz" | tar xz
|
||||||
|
curl -sSL "https://github.com/madler/zlib/archive/v${ZLIB_VERSION}.tar.gz" | tar xz
|
||||||
|
|
||||||
|
- name: Compile nginx
|
||||||
|
run: |
|
||||||
|
source "$GITHUB_WORKSPACE/conf/nginx-configure-flags"
|
||||||
|
cd /tmp/nginx-${NGINX_VERSION}
|
||||||
|
./configure \
|
||||||
|
--prefix=/tmp/nginx-build \
|
||||||
|
--with-pcre=../pcre2-${PCRE_VERSION} \
|
||||||
|
--with-zlib=../zlib-${ZLIB_VERSION} \
|
||||||
|
"${NGINX_CONFIGURE_FLAGS[@]}"
|
||||||
|
sed -i "/CFLAGS/s/ \-O //g" objs/Makefile
|
||||||
|
make -j"$(nproc)"
|
||||||
|
|
||||||
|
- name: Verify nginx binary
|
||||||
|
run: |
|
||||||
|
source "$GITHUB_WORKSPACE/conf/nginx-configure-flags"
|
||||||
|
/tmp/nginx-${NGINX_VERSION}/objs/nginx -V
|
||||||
|
|
||||||
|
- name: Upload release assets
|
||||||
|
if: github.event_name == 'release'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
source "$GITHUB_WORKSPACE/conf/nginx-configure-flags"
|
||||||
|
cp /tmp/nginx-${NGINX_VERSION}/objs/nginx /tmp/nginx-linux-amd64
|
||||||
|
chmod +x /tmp/nginx-linux-amd64
|
||||||
|
gh release upload "${{ github.event.release.tag_name }}" \
|
||||||
|
/tmp/nginx-linux-amd64
|
||||||
91
bin/compile
91
bin/compile
@ -3,17 +3,12 @@
|
|||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
[[ $TRACE ]] && set -x
|
[[ $TRACE ]] && set -x
|
||||||
|
|
||||||
# https://nginx.org/en/download.html
|
# shellcheck source=conf/nginx-configure-flags
|
||||||
NGINX_VERSION="1.29.5"
|
source "$(cd "$(dirname "$0")" && cd .. && pwd)/conf/nginx-configure-flags"
|
||||||
NGINX_TARBALL="nginx-${NGINX_VERSION}.tar.gz"
|
NGINX_TARBALL="nginx-${NGINX_VERSION}.tar.gz"
|
||||||
# https://github.com/PCRE2Project/pcre2/releases
|
|
||||||
PCRE_VERSION="10.47"
|
|
||||||
PCRE_TARBALL="pcre2-${PCRE_VERSION}.tar.gz"
|
PCRE_TARBALL="pcre2-${PCRE_VERSION}.tar.gz"
|
||||||
# https://github.com/gliderlabs/sigil/releases
|
|
||||||
SIGIL_VERSION="0.11.5"
|
|
||||||
# https://github.com/madler/zlib/releases
|
|
||||||
ZLIB_VERSION="1.3.2"
|
|
||||||
ZLIB_TARBALL="zlib-${ZLIB_VERSION}.tar.gz"
|
ZLIB_TARBALL="zlib-${ZLIB_VERSION}.tar.gz"
|
||||||
|
BUILDPACK_REPO="dokku/heroku-buildpack-nginx"
|
||||||
|
|
||||||
suppress() {
|
suppress() {
|
||||||
/bin/rm --force /tmp/surpress.out 2>/dev/null
|
/bin/rm --force /tmp/surpress.out 2>/dev/null
|
||||||
@ -52,6 +47,34 @@ fi
|
|||||||
|
|
||||||
cd "$CACHE_DIR"
|
cd "$CACHE_DIR"
|
||||||
|
|
||||||
|
mkdir -p "$BUILD_DIR/sigil"
|
||||||
|
if [[ ! -f "$BUILD_DIR/sigil/sigil-${SIGIL_VERSION}" ]]; then
|
||||||
|
echo "-----> Download and unzip sigil ${SIGIL_VERSION} via http"
|
||||||
|
curl -fsSL "https://github.com/gliderlabs/sigil/releases/download/v${SIGIL_VERSION}/sigil-linux-amd64" -o "$BUILD_DIR/sigil/sigil-${SIGIL_VERSION}"
|
||||||
|
cp "$BUILD_DIR/sigil/sigil-${SIGIL_VERSION}" "$BUILD_DIR/sigil/sigil"
|
||||||
|
chmod +x "$BUILD_DIR/sigil/sigil"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "$BUILD_DIR/sigil/sigil" ]]; then
|
||||||
|
echo " ! Missing sigil binary"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f "${CACHE_DIR}/bin/nginx" ]]; then
|
||||||
|
echo "-----> Reusing nginx binary from cache"
|
||||||
|
mkdir -p "$BUILD_DIR/nginx"
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
cp -r $CACHE_DIR/bin/* "$BUILD_DIR/nginx/"
|
||||||
|
|
||||||
|
elif curl -fsSL "https://github.com/${BUILDPACK_REPO}/releases/latest/download/nginx-linux-amd64" -o /tmp/nginx-linux-amd64 2>/dev/null; then
|
||||||
|
echo "-----> Using precompiled nginx binary"
|
||||||
|
mkdir -p "$BUILD_DIR/nginx" "${CACHE_DIR}/bin"
|
||||||
|
chmod +x /tmp/nginx-linux-amd64
|
||||||
|
cp /tmp/nginx-linux-amd64 "$BUILD_DIR/nginx/nginx"
|
||||||
|
cp /tmp/nginx-linux-amd64 "${CACHE_DIR}/bin/nginx"
|
||||||
|
rm -f /tmp/nginx-linux-amd64
|
||||||
|
|
||||||
|
else
|
||||||
if [[ ! -d "${NGINX_TARBALL%.tar.gz}" ]]; then
|
if [[ ! -d "${NGINX_TARBALL%.tar.gz}" ]]; then
|
||||||
echo "-----> Download and unzip nginx ${NGINX_VERSION} via http"
|
echo "-----> Download and unzip nginx ${NGINX_VERSION} via http"
|
||||||
curl -sSL "https://nginx.org/download/${NGINX_TARBALL}" -o "${NGINX_TARBALL}"
|
curl -sSL "https://nginx.org/download/${NGINX_TARBALL}" -o "${NGINX_TARBALL}"
|
||||||
@ -70,58 +93,14 @@ if [[ ! -d "${ZLIB_TARBALL%.tar.gz}" ]]; then
|
|||||||
tar xzf "${ZLIB_TARBALL}" && rm -rf "${ZLIB_TARBALL}"
|
tar xzf "${ZLIB_TARBALL}" && rm -rf "${ZLIB_TARBALL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$BUILD_DIR/sigil"
|
|
||||||
if [[ ! -f "$BUILD_DIR/sigil/sigil-${SIGIL_VERSION}" ]]; then
|
|
||||||
echo "-----> Download and unzip sigil ${SIGIL_VERSION} via http"
|
|
||||||
curl -fsSL "https://github.com/gliderlabs/sigil/releases/download/v${SIGIL_VERSION}/sigil-linux-amd64" -o "$BUILD_DIR/sigil/sigil-${SIGIL_VERSION}"
|
|
||||||
cp "$BUILD_DIR/sigil/sigil-${SIGIL_VERSION}" "$BUILD_DIR/sigil/sigil"
|
|
||||||
chmod +x "$BUILD_DIR/sigil/sigil"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -f "$BUILD_DIR/sigil/sigil" ]]; then
|
|
||||||
echo " ! Missing sigil binary"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "nginx-${NGINX_VERSION}"
|
cd "nginx-${NGINX_VERSION}"
|
||||||
if [[ ! -f "${CACHE_DIR}/bin/nginx" ]]; then
|
|
||||||
echo "-----> Compiling static nginx binary"
|
echo "-----> Compiling static nginx binary"
|
||||||
mkdir "$BUILD_DIR/nginx"
|
mkdir "$BUILD_DIR/nginx"
|
||||||
suppress ./configure \
|
suppress ./configure \
|
||||||
--with-cpu-opt=generic \
|
|
||||||
--prefix="$BUILD_DIR/nginx" \
|
--prefix="$BUILD_DIR/nginx" \
|
||||||
--with-pcre=../pcre2-${PCRE_VERSION} \
|
--with-pcre=../pcre2-${PCRE_VERSION} \
|
||||||
--sbin-path=. \
|
|
||||||
--pid-path=./nginx.pid \
|
|
||||||
--conf-path=./nginx.conf \
|
|
||||||
--with-ld-opt="-static" \
|
|
||||||
--with-http_stub_status_module \
|
|
||||||
--with-http_gzip_static_module \
|
|
||||||
--with-file-aio \
|
|
||||||
--with-zlib=../zlib-${ZLIB_VERSION} \
|
--with-zlib=../zlib-${ZLIB_VERSION} \
|
||||||
--with-pcre \
|
"${NGINX_CONFIGURE_FLAGS[@]}"
|
||||||
--with-cc-opt="-O2 -static -static-libgcc" \
|
|
||||||
--without-http_ssi_module \
|
|
||||||
--without-http_userid_module \
|
|
||||||
--without-http_access_module \
|
|
||||||
--without-http_autoindex_module \
|
|
||||||
--without-http_geo_module \
|
|
||||||
--without-http_map_module \
|
|
||||||
--without-http_split_clients_module \
|
|
||||||
--without-http_referer_module \
|
|
||||||
--without-http_fastcgi_module \
|
|
||||||
--without-http_uwsgi_module \
|
|
||||||
--without-http_scgi_module \
|
|
||||||
--without-http_memcached_module \
|
|
||||||
--without-http_empty_gif_module \
|
|
||||||
--without-http_browser_module \
|
|
||||||
--without-http_upstream_ip_hash_module \
|
|
||||||
--without-http_upstream_least_conn_module \
|
|
||||||
--without-http_upstream_keepalive_module \
|
|
||||||
--without-mail_pop3_module \
|
|
||||||
--without-mail_imap_module \
|
|
||||||
--without-mail_smtp_module \
|
|
||||||
--with-http_realip_module
|
|
||||||
|
|
||||||
sed -i "/CFLAGS/s/ \-O //g" objs/Makefile
|
sed -i "/CFLAGS/s/ \-O //g" objs/Makefile
|
||||||
|
|
||||||
@ -130,12 +109,6 @@ if [[ ! -f "${CACHE_DIR}/bin/nginx" ]]; then
|
|||||||
rm -rf "${CACHE_DIR:?}/bin" && mkdir -p "$CACHE_DIR/bin/"
|
rm -rf "${CACHE_DIR:?}/bin" && mkdir -p "$CACHE_DIR/bin/"
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
cp -r $BUILD_DIR/nginx/* "$CACHE_DIR/bin/"
|
cp -r $BUILD_DIR/nginx/* "$CACHE_DIR/bin/"
|
||||||
|
|
||||||
else
|
|
||||||
echo "-----> Reusing nginx binary from cache"
|
|
||||||
mkdir -p "$BUILD_DIR/nginx"
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
cp -r $CACHE_DIR/bin/* "$BUILD_DIR/nginx/"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update the PATH
|
# Update the PATH
|
||||||
|
|||||||
47
conf/nginx-configure-flags
Normal file
47
conf/nginx-configure-flags
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Shared nginx build configuration
|
||||||
|
# Sourced by bin/compile and .github/workflows/release.yml
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
|
||||||
|
# https://nginx.org/en/download.html
|
||||||
|
NGINX_VERSION="1.29.8"
|
||||||
|
# https://github.com/PCRE2Project/pcre2/releases
|
||||||
|
PCRE_VERSION="10.47"
|
||||||
|
# https://github.com/gliderlabs/sigil/releases
|
||||||
|
SIGIL_VERSION="0.11.5"
|
||||||
|
# https://github.com/madler/zlib/releases
|
||||||
|
ZLIB_VERSION="1.3.2"
|
||||||
|
|
||||||
|
NGINX_CONFIGURE_FLAGS=(
|
||||||
|
--with-cpu-opt=generic
|
||||||
|
--sbin-path=.
|
||||||
|
--pid-path=./nginx.pid
|
||||||
|
--conf-path=./nginx.conf
|
||||||
|
"--with-ld-opt=-static"
|
||||||
|
--with-http_stub_status_module
|
||||||
|
--with-http_gzip_static_module
|
||||||
|
--with-file-aio
|
||||||
|
--with-pcre
|
||||||
|
"--with-cc-opt=-O2 -static -static-libgcc"
|
||||||
|
--without-http_ssi_module
|
||||||
|
--without-http_userid_module
|
||||||
|
--without-http_access_module
|
||||||
|
--without-http_autoindex_module
|
||||||
|
--without-http_geo_module
|
||||||
|
--without-http_map_module
|
||||||
|
--without-http_split_clients_module
|
||||||
|
--without-http_referer_module
|
||||||
|
--without-http_fastcgi_module
|
||||||
|
--without-http_uwsgi_module
|
||||||
|
--without-http_scgi_module
|
||||||
|
--without-http_memcached_module
|
||||||
|
--without-http_empty_gif_module
|
||||||
|
--without-http_browser_module
|
||||||
|
--without-http_upstream_ip_hash_module
|
||||||
|
--without-http_upstream_least_conn_module
|
||||||
|
--without-http_upstream_keepalive_module
|
||||||
|
--without-mail_pop3_module
|
||||||
|
--without-mail_imap_module
|
||||||
|
--without-mail_smtp_module
|
||||||
|
--with-http_realip_module
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user