tcpasters/oci/Containerfile.http
Thorsten Schubert 762bf9ed8e
All checks were successful
continuous-integration/drone/push Build is passing
OCI compatible container configuration
2022-09-17 10:03:52 +02:00

63 lines
2.2 KiB
HTTP

# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright © 2022 Thorsten Schubert <tschubert@bafh.org>
ARG NGINX_VERSION=1.23.1
FROM docker.io/library/nginx:${NGINX_VERSION}-alpine AS builder
ARG NGINX_VERSION=1.23.1
ARG HEADERS_MORE_VERSION=v0.34
RUN apk add --no-cache --virtual .build-deps \
autoconf \
automake \
g++ \
gcc \
git \
libc-dev \
libtool \
linux-headers \
make \
openssl-dev \
pcre-dev \
shadow \
zlib-dev
RUN mkdir -p /usr/src \
&& cd /usr/src \
&& git clone --depth 1 -b ${HEADERS_MORE_VERSION} --single-branch https://github.com/openresty/headers-more-nginx-module.git \
&& cd /usr/src/headers-more-nginx-module \
&& git submodule update --init \
&& cd /usr/src \
&& wget -O - http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar zxfv - \
&& mv /usr/src/nginx-${NGINX_VERSION} /usr/src/nginx \
&& cd /usr/src/nginx \
&& ./configure --with-compat --add-dynamic-module=/usr/src/headers-more-nginx-module \
&& make modules
FROM docker.io/library/nginx:${NGINX_VERSION}-alpine
COPY --from=builder /usr/src/nginx/objs/ngx_http_headers_more_filter_module.so /usr/lib/nginx/modules
ARG PUID=1000
ARG PGID=1000
RUN apk add --no-cache --virtual .build-deps shadow \
&& usermod -u ${PUID} nginx \
&& groupmod -g ${PGID} nginx \
&& chown -R ${PUID}:0 /var/cache/nginx /etc/nginx \
&& sed -i 's,listen 80;,listen 8080;,' /etc/nginx/conf.d/default.conf \
&& sed -i '/user nginx;/d' /etc/nginx/nginx.conf \
&& sed -i 's,/var/run/nginx.pid,/tmp/nginx.pid,' /etc/nginx/nginx.conf \
&& sed -i "/^http {/a \ proxy_temp_path /tmp/proxy_temp;\n client_body_temp_path /tmp/client_temp;\n fastcgi_temp_path /tmp/fastcgi_temp;\n uwsgi_temp_path /tmp/uwsgi_temp;\n scgi_temp_path /tmp/scgi_temp;\n" /etc/nginx/nginx.conf \
&& chown -R ${PUID}:0 /var/cache/nginx /etc/nginx /var/log/nginx \
&& chmod -R g+w /var/cache/nginx /etc/nginx /var/log/nginx \
&& apk del .build-deps
COPY --chown=nginx:root oci/rootfs/http/etc/nginx/nginx.conf /etc/nginx/nginx.conf
USER $PUID
CMD ["nginx", "-g", "daemon off;"]
# vi: set ft=dockerfile ts=2 sw=2 sts=0 nosr et si tw=0 fdm=manual: