Skip to content

Commit

Permalink
Merge pull request #4863 from aledbf/switch-nginx
Browse files Browse the repository at this point in the history
Switch to nginx again
  • Loading branch information
aledbf committed Jan 4, 2020
2 parents f42f559 + 048ce1a commit eb3fd57
Show file tree
Hide file tree
Showing 12 changed files with 615 additions and 163 deletions.
8 changes: 2 additions & 6 deletions images/nginx/Makefile
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

# 0.0.0 shouldn't clobber any released builds
TAG ?= 0.94
TAG ?= 0.95
REGISTRY ?= quay.io/kubernetes-ingress-controller
ARCH ?= $(shell go env GOARCH)
DOCKER ?= docker
Expand All @@ -26,15 +26,12 @@ ifeq ($(GOHOSTOS),darwin)
SED_I=sed -i ''
endif

QEMUVERSION=v4.1.0-1
QEMUVERSION=v4.1.1-1

IMGNAME = nginx
IMAGE = $(REGISTRY)/$(IMGNAME)
MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)

# Set default base image dynamically for each arch
BASEIMAGE?=quay.io/kubernetes-ingress-controller/debian-base-$(ARCH):0.1

ifeq ($(ARCH),arm)
QEMUARCH=arm
endif
Expand Down Expand Up @@ -62,7 +59,6 @@ all-push: $(addprefix sub-push-,$(ALL_ARCH))
container: .container-$(ARCH)
.container-$(ARCH):
cp -r ./rootfs/* $(TEMP_DIR)
cd $(TEMP_DIR) && $(SED_I) 's|BASEIMAGE|$(BASEIMAGE)|g' Dockerfile
cd $(TEMP_DIR) && $(SED_I) "s|ARCH|$(QEMUARCH)|g" Dockerfile

ifeq ($(ARCH),amd64)
Expand Down
6 changes: 2 additions & 4 deletions images/nginx/README.md
@@ -1,6 +1,4 @@
OpenResty base image using [debian-base](https://quay.io/kubernetes-ingress-controller/debian-base-amd64)

OpenResty® is a dynamic web platform based on NGINX and LuaJIT.
NGINX base image using [alpine](https://www.alpinelinux.org/)

This custom image contains:

Expand All @@ -20,7 +18,7 @@ This image provides a default configuration file with no backend servers.
_Using docker_

```console
docker run -v /some/nginx.con:/etc/nginx/nginx.conf:ro quay.io/kubernetes-ingress-controller/nginx:0.90
docker run -v /some/nginx.con:/etc/nginx/nginx.conf:ro quay.io/kubernetes-ingress-controller/nginx:0.95
```

_Creating a replication controller_
Expand Down
4 changes: 2 additions & 2 deletions images/nginx/rc.yaml
@@ -1,7 +1,7 @@
apiVersion: v1
kind: Service
metadata:
name: nginxsvc
name: nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
Expand Down Expand Up @@ -38,7 +38,7 @@ spec:
spec:
containers:
- name: nginx
image: quay.io/kubernetes-ingress-controller/nginx:0.90
image: quay.io/kubernetes-ingress-controller/nginx:0.95
ports:
- containerPort: 80
- containerPort: 443
58 changes: 49 additions & 9 deletions images/nginx/rootfs/Dockerfile
Expand Up @@ -13,22 +13,62 @@
# limitations under the License.


FROM BASEIMAGE
FROM alpine:3.11 as builder

CROSS_BUILD_COPY qemu-ARCH-static /usr/bin/

ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
COPY . /

# Add LuaRocks paths
# see https://github.com/openresty/docker-openresty/blob/de05cd72594498b83e3a97e2f632da6aa75ec01d/bionic/Dockerfile#L168
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.0-beta3/?.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;/usr/local/lib/lua/?.lua"
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"
RUN apk add -U bash \
&& /build.sh

COPY . /
# Use a multi-stage build
FROM alpine:3.11

ENV PATH=$PATH:/usr/local/luajit/bin:/usr/local/nginx/sbin:/usr/local/nginx/bin

ENV LUA_PATH="/usr/local/share/luajit-2.1.0-beta3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/lib/lua/?.lua;;"
ENV LUA_CPATH="/usr/local/lib/lua/?/?.so;/usr/local/lib/lua/?.so;;"

RUN clean-install bash
COPY --from=builder /usr/local /usr/local
COPY --from=builder /opt /opt
COPY --from=builder /etc/nginx /etc/nginx

RUN /build.sh
RUN apk add -U --no-cache \
bash \
openssl \
pcre \
zlib \
geoip \
curl ca-certificates \
patch \
yajl \
lmdb \
libxml2 \
libmaxminddb \
yaml-cpp \
dumb-init \
nano \
tzdata \
&& ln -s /usr/local/nginx/sbin/nginx /sbin/nginx \
&& ln -s /usr/local/lib/mimalloc-1.2/libmimalloc.so /usr/local/lib/libmimalloc.so \
&& addgroup -Sg 101 www-data \
&& adduser -S -D -H -u 101 -h /usr/local/nginx \
-s /sbin/nologin -G www-data -g www-data www-data \
&& bash -eu -c ' \
writeDirs=( \
/var/log/nginx \
/var/lib/nginx/body \
/var/lib/nginx/fastcgi \
/var/lib/nginx/proxy \
/var/lib/nginx/scgi \
/var/lib/nginx/uwsgi \
/var/log/audit \
); \
for dir in "${writeDirs[@]}"; do \
mkdir -p ${dir}; \
chown -R www-data.www-data ${dir}; \
done'

EXPOSE 80 443

Expand Down

0 comments on commit eb3fd57

Please sign in to comment.