|
| 1 | +# Dockerfile - buildpack-deps |
| 2 | +# https://github.com/openresty/docker-openresty |
| 3 | + |
| 4 | +ARG RESTY_IMAGE_BASE="buildpack-deps" |
| 5 | +ARG RESTY_IMAGE_TAG="bookworm" |
| 6 | + |
| 7 | +FROM ${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG} |
| 8 | + |
| 9 | +LABEL maintainer="Evan Wies <evan@neomantra.net>" |
| 10 | + |
| 11 | +# RESTY_DEB_FLAVOR build argument is used to select other |
| 12 | +# OpenResty Debian package variants. |
| 13 | +# For example: "-debug" or "-valgrind" |
| 14 | +ARG RESTY_DEB_FLAVOR="" |
| 15 | +ARG RESTY_DEB_VERSION="=1.27.1.1-1~bookworm1" |
| 16 | +ARG RESTY_APT_REPO="https://openresty.org/package/debian" |
| 17 | +ARG RESTY_APT_PGP="https://openresty.org/package/pubkey.gpg" |
| 18 | +ARG RESTY_APT_ARCH="amd64" |
| 19 | +ARG RESTY_IMAGE_BASE="buildpack-deps" |
| 20 | +ARG RESTY_IMAGE_TAG="bookworm" |
| 21 | + |
| 22 | +ARG RESTY_LUAROCKS_VERSION="3.11.1" |
| 23 | + |
| 24 | +LABEL resty_image_base="${RESTY_IMAGE_BASE}" |
| 25 | +LABEL resty_image_tag="${RESTY_IMAGE_TAG}" |
| 26 | +LABEL resty_apt_repo="${RESTY_APT_REPO}" |
| 27 | +LABEL resty_apt_pgp="${RESTY_APT_PGP}" |
| 28 | +LABEL resty_apt_arch="${RESTY_APT_ARCH}" |
| 29 | +LABEL resty_deb_flavor="${RESTY_DEB_FLAVOR}" |
| 30 | +LABEL resty_deb_version="${RESTY_DEB_VERSION}" |
| 31 | +LABEL resty_luarocks_version="${RESTY_LUAROCKS_VERSION}}" |
| 32 | + |
| 33 | +# Install OpenResty |
| 34 | +RUN wget -qO - ${RESTY_APT_PGP} | gpg --dearmor > /etc/apt/trusted.gpg.d/openresty-keyring.gpg \ |
| 35 | + && chown root:root /etc/apt/trusted.gpg.d/openresty-keyring.gpg \ |
| 36 | + && chmod ugo+r /etc/apt/trusted.gpg.d/openresty-keyring.gpg \ |
| 37 | + && chmod go-w /etc/apt/trusted.gpg.d/openresty-keyring.gpg \ |
| 38 | + && echo "deb [arch=$RESTY_APT_ARCH signed-by=/etc/apt/trusted.gpg.d/openresty-keyring.gpg] $RESTY_APT_REPO $(grep -Po 'VERSION="[0-9]+ \(\K[^)]+' /etc/os-release) openresty" | tee /etc/apt/sources.list.d/openresty.list \ |
| 39 | + && DEBIAN_FRONTEND=noninteractive apt-get update \ |
| 40 | + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ |
| 41 | + openresty${RESTY_DEB_FLAVOR}${RESTY_DEB_VERSION} \ |
| 42 | + openresty-resty${RESTY_FAT_DEB_FLAVOR}${RESTY_FAT_DEB_VERSION} \ |
| 43 | + openresty-opm${RESTY_FAT_DEB_FLAVOR}${RESTY_FAT_DEB_VERSION} \ |
| 44 | + && mkdir -p /var/run/openresty \ |
| 45 | + && ln -sf /dev/stdout /usr/local/openresty${RESTY_DEB_FLAVOR}/nginx/logs/access.log \ |
| 46 | + && ln -sf /dev/stderr /usr/local/openresty${RESTY_DEB_FLAVOR}/nginx/logs/error.log |
| 47 | + |
| 48 | +# Install LuaRocks |
| 49 | +RUN curl -fSL https://luarocks.github.io/luarocks/releases/luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz -o luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \ |
| 50 | + && tar xzf luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \ |
| 51 | + && cd luarocks-${RESTY_LUAROCKS_VERSION} \ |
| 52 | + && ./configure \ |
| 53 | + --prefix=/usr/local/openresty/luajit \ |
| 54 | + --with-lua=/usr/local/openresty/luajit \ |
| 55 | + --with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1 \ |
| 56 | + && make build \ |
| 57 | + && make install \ |
| 58 | + && cd /tmp \ |
| 59 | + && rm -rf luarocks-${RESTY_LUAROCKS_VERSION} luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz |
| 60 | + |
| 61 | +# Add additional binaries into PATH for convenience |
| 62 | +ENV PATH="$PATH:/usr/local/openresty${RESTY_DEB_FLAVOR}/luajit/bin:/usr/local/openresty${RESTY_DEB_FLAVOR}/nginx/sbin:/usr/local/openresty${RESTY_DEB_FLAVOR}/bin" |
| 63 | + |
| 64 | +# Add LuaRocks paths |
| 65 | +# If OpenResty changes, these may need updating: |
| 66 | +# /usr/local/openresty/bin/resty -e 'print(package.path)' |
| 67 | +# /usr/local/openresty/bin/resty -e 'print(package.cpath)' |
| 68 | +ENV LUA_PATH="/usr/local/openresty/site/lualib/?.ljbc;/usr/local/openresty/site/lualib/?/init.ljbc;/usr/local/openresty/lualib/?.ljbc;/usr/local/openresty/lualib/?/init.ljbc;/usr/local/openresty/site/lualib/?.lua;/usr/local/openresty/site/lualib/?/init.lua;/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua;./?.lua;/usr/local/openresty/luajit/share/luajit-2.1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/openresty/luajit/share/lua/5.1/?.lua;/usr/local/openresty/luajit/share/lua/5.1/?/init.lua" |
| 69 | +ENV LUA_CPATH="/usr/local/openresty/site/lualib/?.so;/usr/local/openresty/lualib/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so" |
| 70 | + |
| 71 | +# Copy nginx configuration files |
| 72 | +COPY nginx.conf /usr/local/openresty${RESTY_DEB_FLAVOR}/nginx/conf/nginx.conf |
| 73 | +COPY nginx.vh.default.conf /etc/nginx/conf.d/default.conf |
| 74 | + |
| 75 | +CMD ["/usr/bin/openresty", "-g", "daemon off;"] |
| 76 | + |
| 77 | +# Use SIGQUIT instead of default SIGTERM to cleanly drain requests |
| 78 | +# See https://github.com/openresty/docker-openresty/blob/master/README.md#tips--pitfalls |
| 79 | +STOPSIGNAL SIGQUIT |
0 commit comments