diff --git a/.github/workflows/push-apisix-base-image.yml b/.github/workflows/push-apisix-base-image.yml index ca795cef7..3d6527614 100644 --- a/.github/workflows/push-apisix-base-image.yml +++ b/.github/workflows/push-apisix-base-image.yml @@ -46,3 +46,6 @@ jobs: docker buildx build -t api7/apisix-base:${{ steps.tag_env.outputs.version }} --push \ --build-arg VERSION=${{ steps.tag_env.outputs.version }} --platform linux/amd64,linux/arm64 \ -f ./dockerfiles/Dockerfile.apisix-base.apk . + docker buildx build -t api7/apisix-base:${{ steps.tag_env.outputs.version }}-debian --push \ + --build-arg VERSION=${{ steps.tag_env.outputs.version }} --platform linux/amd64,linux/arm64 \ + -f ./dockerfiles/Dockerfile.apisix-base.minideb . diff --git a/build-apisix-base.sh b/build-apisix-base.sh index 108f435fb..f30caf088 100755 --- a/build-apisix-base.sh +++ b/build-apisix-base.sh @@ -88,6 +88,8 @@ cd apisix-nginx-module/patch || exit 1 cd ../.. cd wasm-nginx-module || exit 1 +if [ -z $TARGETARCH ] ; then export TARGETARCH="amd64"; fi +if [ "$TARGETARCH" = "arm64" ] ; then sed -i 's/x86_64/aarch64/g' ./install-wasmtime.sh; fi ./install-wasmtime.sh cd .. diff --git a/dockerfiles/Dockerfile.apisix-base.apk b/dockerfiles/Dockerfile.apisix-base.apk index cc6527fb2..9870c263b 100644 --- a/dockerfiles/Dockerfile.apisix-base.apk +++ b/dockerfiles/Dockerfile.apisix-base.apk @@ -17,6 +17,7 @@ ARG RESTY_PCRE_VERSION="8.44" ARG RESTY_J="1" ARG RESTY_EVAL_PRE_CONFIGURE="" ARG VERSION +ARG TARGETARCH LABEL resty_image_base="${RESTY_IMAGE_BASE}" LABEL resty_image_tag="${IMAGE_TAG}" @@ -85,6 +86,7 @@ RUN cd /tmp \ && make -j${RESTY_J} install ENV version=${VERSION} +ENV TARGETARCH=${TARGETARCH} RUN cd /tmp \ && curl --version \ && source /root/.cargo/env \ diff --git a/dockerfiles/Dockerfile.apisix-base.deb b/dockerfiles/Dockerfile.apisix-base.deb index 0887e7dff..e4ba81bae 100644 --- a/dockerfiles/Dockerfile.apisix-base.deb +++ b/dockerfiles/Dockerfile.apisix-base.deb @@ -12,10 +12,12 @@ WORKDIR /tmp ARG VERSION ARG IMAGE_BASE ARG IMAGE_TAG +ARG TARGETARCH ENV IMAGE_BASE=${IMAGE_BASE} ENV IMAGE_TAG=${IMAGE_TAG} ENV version=${VERSION} +ENV TARGETARCH=${TARGETARCH} RUN ./build-common.sh build_apisix_base_deb \ # determine dist and write it into /tmp/dist file diff --git a/dockerfiles/Dockerfile.apisix-base.minideb b/dockerfiles/Dockerfile.apisix-base.minideb new file mode 100644 index 000000000..2a4252557 --- /dev/null +++ b/dockerfiles/Dockerfile.apisix-base.minideb @@ -0,0 +1,113 @@ +FROM --platform=amd64 bitnami/minideb:bullseye as build + +COPY ./utils/build-common.sh \ + ./utils/install-common.sh \ + build-apisix-base.sh \ + ./utils/determine-dist.sh \ + /tmp/ + +ARG RESTY_OPENSSL_VERSION="1.1.1g" +ARG RESTY_OPENSSL_PATCH_VERSION="1.1.1f" +ARG RESTY_OPENSSL_URL_BASE="https://www.openssl.org/source" +ARG RESTY_PCRE_VERSION="8.44" +ARG RESTY_J="1" +ARG RESTY_EVAL_PRE_CONFIGURE="" +ARG VERSION +ARG TARGETARCH + +LABEL resty_image_base="${RESTY_IMAGE_BASE}" +LABEL resty_image_tag="${IMAGE_TAG}" +LABEL resty_openssl_version="${RESTY_OPENSSL_VERSION}" +LABEL resty_openssl_patch_version="${RESTY_OPENSSL_PATCH_VERSION}" +LABEL resty_openssl_url_base="${RESTY_OPENSSL_URL_BASE}" +LABEL resty_pcre_version="${RESTY_PCRE_VERSION}" +LABEL resty_eval_pre_configure="${RESTY_EVAL_PRE_CONFIGURE}" + +RUN dpkg --add-architecture ${TARGETARCH} \ + && install_packages ca-certificates \ + curl \ + wget \ + git \ + gettext-base \ + patch \ + xz-utils \ + sudo \ + make \ + perl \ + unzip \ + libgd-dev:${TARGETARCH} \ + libgeoip-dev:${TARGETARCH} \ + libncurses5-dev:${TARGETARCH} \ + libperl-dev:${TARGETARCH} \ + libreadline-dev:${TARGETARCH} \ + libxslt1-dev:${TARGETARCH} \ + zlib1g-dev:${TARGETARCH} \ + && if [ "${TARGETARCH}" = "amd64" ] ; then install_packages gcc g++; fi \ + && if [ "${TARGETARCH}" = "arm64" ] ; then \ + install_packages gcc-aarch64-linux-gnu g++-aarch64-linux-gnu; \ + ln /usr/bin/aarch64-linux-gnu-gcc /usr/bin/cc; \ + ln /usr/bin/aarch64-linux-gnu-gcc /usr/bin/gcc; \ + ln /usr/bin/aarch64-linux-gnu-ar /usr/bin/ar; \ + ln /usr/bin/aarch64-linux-gnu-ranlib /usr/bin/ranlib; \ + ln /usr/bin/aarch64-linux-gnu-g++ /usr/bin/g++; \ + fi \ + && gcc -v \ + && g++ -v + +RUN echo ${TARGETARCH} \ + && cd /tmp \ + && if [ -n "${RESTY_EVAL_PRE_CONFIGURE}" ]; then eval $(echo ${RESTY_EVAL_PRE_CONFIGURE}); fi \ + && cd /tmp \ + && curl -fSL "${RESTY_OPENSSL_URL_BASE}/openssl-${RESTY_OPENSSL_VERSION}.tar.gz" -o openssl-${RESTY_OPENSSL_VERSION}.tar.gz \ + && tar xzf openssl-${RESTY_OPENSSL_VERSION}.tar.gz \ + && cd openssl-${RESTY_OPENSSL_VERSION} \ + && echo 'patching OpenSSL 1.1.1 for OpenResty' \ + && curl -s https://raw.githubusercontent.com/openresty/openresty/master/patches/openssl-${RESTY_OPENSSL_PATCH_VERSION}-sess_set_get_cb_yield.patch | patch -p1 \ + && if [ "${TARGETARCH}" = "arm64" ] ; then export MACHINE=aarch64; fi \ + && ./config \ + no-threads shared zlib -g \ + enable-ssl3 enable-ssl3-method \ + --prefix=/usr/local/openresty/openssl111 \ + --libdir=lib \ + -Wl,-rpath,/usr/local/openresty/openssl111/lib \ + && make -j${RESTY_J} \ + && make -j${RESTY_J} install_sw + +RUN echo ${TARGETARCH} \ + && cd /tmp \ + && curl -fSL https://downloads.sourceforge.net/project/pcre/pcre/${RESTY_PCRE_VERSION}/pcre-${RESTY_PCRE_VERSION}.tar.gz -o pcre-${RESTY_PCRE_VERSION}.tar.gz \ + && tar xzf pcre-${RESTY_PCRE_VERSION}.tar.gz \ + && cd /tmp/pcre-${RESTY_PCRE_VERSION} \ + && ./configure \ + --prefix=/usr/local/openresty/pcre \ + --disable-cpp \ + --enable-jit \ + --enable-utf \ + --enable-unicode-properties \ + && make -j${RESTY_J} \ + && make -j${RESTY_J} install + +ENV version=${VERSION} +ENV TARGETARCH=${TARGETARCH} + +RUN echo ${TARGETARCH} \ + && cd /tmp \ + && curl --version \ + && ./build-common.sh build_apisix_base_minideb \ + && ./install-common.sh install_lua \ + && ./install-common.sh install_luarocks \ + && rm -f /usr/local/openresty/wasmtime-c-api/lib/libwasmtime.a \ + && /usr/local/openresty/bin/openresty -V + +FROM bitnami/minideb:bullseye as prod + +COPY --from=build /usr/local/openresty /usr/local/openresty + +RUN install_packages libgd3 \ + libgeoip1 \ + libxslt1.1 \ + zlib1g + +ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin + +CMD /bin/sh diff --git a/dockerfiles/Dockerfile.apisix-base.rpm b/dockerfiles/Dockerfile.apisix-base.rpm index 051314bc9..1118aaefa 100644 --- a/dockerfiles/Dockerfile.apisix-base.rpm +++ b/dockerfiles/Dockerfile.apisix-base.rpm @@ -12,10 +12,12 @@ WORKDIR /tmp ARG VERSION ARG IMAGE_BASE ARG IMAGE_TAG +ARG TARGETARCH ENV IMAGE_BASE=${IMAGE_BASE} ENV IMAGE_TAG=${IMAGE_TAG} ENV version=${VERSION} +ENV TARGETARCH=${TARGETARCH} RUN ./build-common.sh build_apisix_base_rpm \ # determine dist and write it into /tmp/dist file diff --git a/utils/build-common.sh b/utils/build-common.sh index 505651884..81780edb1 100755 --- a/utils/build-common.sh +++ b/utils/build-common.sh @@ -31,6 +31,11 @@ build_apisix_base_deb() { ./build-apisix-base.sh } +build_apisix_base_minideb() { + export_openresty_variables + ./build-apisix-base.sh +} + build_apisix_base_apk() { export_openresty_variables ./build-apisix-base.sh @@ -55,6 +60,9 @@ build_apisix_base_rpm) build_apisix_base_deb) build_apisix_base_deb ;; +build_apisix_base_minideb) + build_apisix_base_minideb + ;; build_apisix_base_apk) build_apisix_base_apk ;;