Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to nginx again #4863

Merged
merged 3 commits into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Migrate to alpine linux
  • Loading branch information
aledbf committed Dec 29, 2019
commit 048ce1a130fc1a664c987d1e4829d96ba1422e59
4 changes: 0 additions & 4 deletions images/nginx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ 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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
43 changes: 19 additions & 24 deletions images/nginx/rootfs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
# limitations under the License.


FROM BASEIMAGE as builder
FROM alpine:3.11 as builder

CROSS_BUILD_COPY qemu-ARCH-static /usr/bin/

RUN clean-install bash

COPY . /

RUN /build.sh
RUN apk add -U bash \
&& /build.sh

# Use a multi-stage build
FROM BASEIMAGE
FROM alpine:3.11

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

Expand All @@ -33,33 +32,29 @@ ENV LUA_CPATH="/usr/local/lib/lua/?/?.so;/usr/local/lib/lua/?.so;;"

COPY --from=builder /usr/local /usr/local
COPY --from=builder /opt /opt
COPY --chown=www-data:www-data --from=builder /etc/nginx /etc/nginx
COPY --from=builder /etc/nginx /etc/nginx

RUN apt-get update && apt-get dist-upgrade -y \
&& clean-install \
RUN apk add -U --no-cache \
bash \
openssl \
pcre \
zlib \
geoip \
curl ca-certificates \
libgeoip1 \
patch \
libpcre3 \
zlib1g \
libaio1 \
openssl \
util-linux \
lmdb-utils \
libcurl4 \
libprotobuf17 \
libz3-4 \
procps \
libxml2 libpcre++0v5 \
liblmdb0 \
libmaxminddb0 \
yajl \
lmdb \
libxml2 \
libmaxminddb \
yaml-cpp \
dumb-init \
nano \
libyaml-cpp0.6 \
libyajl2 \
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 \
Expand Down
70 changes: 30 additions & 40 deletions images/nginx/rootfs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,47 +67,47 @@ get_src()
rm -rf "$f"
}

apt-get update && apt-get dist-upgrade -y
apk update
apk upgrade

# install required packages to build
clean-install \
apk add \
bash \
build-essential \
gcc \
clang \
libc-dev \
make \
automake \
openssl-dev \
pcre-dev \
zlib-dev \
linux-headers \
libxslt-dev \
gd-dev \
geoip-dev \
perl-dev \
libedit-dev \
mercurial \
alpine-sdk \
findutils \
curl ca-certificates \
libgeoip1 \
libgeoip-dev \
geoip-dev \
patch \
libpcre3 \
libpcre3-dev \
libssl-dev \
zlib1g \
zlib1g-dev \
libaio1 \
libaio-dev \
openssl \
libperl-dev \
cmake \
util-linux \
lmdb-utils \
lmdb-tools \
wget \
libcurl4-openssl-dev \
libprotobuf-dev protobuf-compiler \
libz-dev \
git g++ pkgconf flex bison doxygen libyajl-dev liblmdb-dev libtool dh-autoreconf libxml2 libpcre++-dev libxml2-dev \
curl-dev \
libprotobuf \
git g++ pkgconf flex bison doxygen yajl-dev lmdb-dev libtool autoconf libxml2 pcre-dev libxml2-dev \
python \
libmaxminddb-dev \
bc \
unzip \
dos2unix mercurial \
libyaml-cpp0.6 \
|| exit 1

# https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1667178.html
if [[ ${ARCH} == "armv7l" ]]; then
echo "Fixing ca-certificates"
touch /etc/ssl/certs/ca-certificates.crt
c_rehash
fi
yaml-cpp

mkdir -p /etc/nginx

Expand Down Expand Up @@ -229,18 +229,6 @@ cd "$BUILD_PATH/luajit2-$LUAJIT_VERSION"
make CCDEBUG=-g
make install

if [[ ${ARCH} == "armv7l" ]]; then
export PCRE_DIR=/usr/lib/arm-linux-gnueabihf
fi

if [[ ${ARCH} == "x86_64" ]]; then
export PCRE_DIR=/usr/lib/x86_64-linux-gnu
fi

if [[ ${ARCH} == "aarch64" ]]; then
export PCRE_DIR=/usr/lib/aarch64-linux-gnu
fi

cd "$BUILD_PATH"

# install openresty-gdb-utils
Expand Down Expand Up @@ -554,7 +542,7 @@ export LUA_INCLUDE_DIR=/usr/local/include/luajit-2.1
ln -s $LUA_INCLUDE_DIR /usr/include/lua5.1

if [[ ${ARCH} != "armv7l" ]]; then
luarocks install lrexlib-pcre 2.7.2-1 PCRE_LIBDIR=${PCRE_DIR}
luarocks install lrexlib-pcre 2.7.2-1
fi

cd "$BUILD_PATH/lua-resty-core-$LUA_RESTY_CORE"
Expand Down Expand Up @@ -583,7 +571,6 @@ make install
cd "$BUILD_PATH/lua-resty-string-0.11"
make install


# build Lua bridge tracer
cd "$BUILD_PATH/lua-bridge-tracer-$LUA_BRIDGE_TRACER_VERSION"
mkdir .build
Expand Down Expand Up @@ -613,6 +600,9 @@ writeDirs=( \
/var/log/nginx \
);

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

for dir in "${writeDirs[@]}"; do
mkdir -p ${dir};
chown -R www-data.www-data ${dir};
Expand Down