diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 000000000000..75ceda392d30 --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,13 @@ +ARG RESTY_IMAGE_BASE +ARG RESTY_IMAGE_TAG + +FROM alpine + +RUN apk update \ + && apk add ca-certificates wget \ + && update-ca-certificates \ + && apk add --virtual build-deps make gcc make g++ zlib-dev musl-dev pcre-dev \ + openssl-dev zlib-dev ncurses-dev readline-dev curl perl \ + libffi-dev git unzip tar openssh m4 xz gnupg openssl musl \ + linux-headers bsd-compat-headers bash + diff --git a/Dockerfile.openresty b/Dockerfile.openresty index 4017bb67f19f..486952e09967 100644 --- a/Dockerfile.openresty +++ b/Dockerfile.openresty @@ -3,6 +3,7 @@ ARG RESTY_IMAGE_TAG="xenial" FROM kong:${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} +ARG OPENSSL_EXTRA_OPTIONS ARG RESTY_VERSION="1.13.6.2" ARG RESTY_LUAROCKS_VERSION="2.4.3" ARG RESTY_OPENSSL_VERSION="1.1.1" @@ -46,10 +47,8 @@ RUN cd /tmp \ && for i in /tmp/openresty-patches-master/patches/${RESTY_VERSION}/*.patch; do patch -p1 < $i; done RUN cd /tmp/openssl-${RESTY_OPENSSL_VERSION} \ - && eval ./config \ - --prefix=/tmp/build/usr/local/kong \ - --openssldir=/tmp/build/usr/local/kong \ - shared \ + && export OPENSSL_OPTIONS="--prefix=/tmp/build/usr/local/kong --openssldir=/tmp/build/usr/local/kong $OPENSSL_EXTRA_OPTIONS" \ + && eval ./config $OPENSSL_OPTIONS shared \ && make -j${RESTY_J} RUN cd /tmp/openresty-${RESTY_VERSION} \ diff --git a/Makefile b/Makefile index df068e735321..34080861a866 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,10 @@ RESTY_LUAROCKS_VERSION?="2.4.3" RESTY_OPENSSL_VERSION?="1.1.1" RESTY_PCRE_VERSION?="8.41" +ifeq ($(RESTY_IMAGE_BASE),alpine) + OPENSSL_EXTRA_OPTIONS=" -no-async" +endif + KONG_PACKAGE_NAME?="kong-community-edition" KONG_CONFLICTS?="kong-enterprise-edition" KONG_LICENSE?="ASL 2.0" @@ -42,7 +46,6 @@ package-kong: build-kong -e RESTY_IMAGE_TAG=$(RESTY_IMAGE_TAG) \ -e RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \ kong:fpm - build-kong: build-openresty-base docker build -f Dockerfile.kong \ @@ -68,19 +71,12 @@ build-openresty-base: build-base --build-arg RESTY_PCRE_VERSION=$(RESTY_PCRE_VERSION) \ --build-arg RESTY_IMAGE_TAG="$(RESTY_IMAGE_TAG)" \ --build-arg RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \ + --build-arg OPENSSL_EXTRA_OPTIONS=$(OPENSSL_EXTRA_OPTIONS) \ -t kong:openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG) . + build-base: ifeq ($(RESTY_IMAGE_BASE),rhel) - make build-rhel-base -else - docker build -f Dockerfile.$(RESTY_IMAGE_BASE) \ - --build-arg RESTY_IMAGE_TAG="$(RESTY_IMAGE_TAG)" \ - --build-arg RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \ - -t kong:$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG) . -endif - -build-rhel-base: @docker build -f Dockerfile.rhel \ --build-arg RESTY_IMAGE_BASE=registry.access.redhat.com/rhel${RESTY_IMAGE_TAG} \ --build-arg RESTY_IMAGE_TAG=latest \ @@ -88,3 +84,9 @@ build-rhel-base: --build-arg REDHAT_USERNAME=$(REDHAT_USERNAME) \ --build-arg REDHAT_PASSWORD=$(REDHAT_PASSWORD) \ -t kong:$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG) . +else + docker build -f Dockerfile.$(RESTY_IMAGE_BASE) \ + --build-arg RESTY_IMAGE_TAG="$(RESTY_IMAGE_TAG)" \ + --build-arg RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \ + -t kong:$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG) . +endif diff --git a/README.md b/README.md index b6eeb10b2671..116a18d430ab 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,8 @@ The most common ones are the following: KONG_SOURCE_LOCATION=/src/projects/custom-kong-location KONG_PACKAGE_NAME=custom-kong-name KONG_VERSION=v1.0.0 -RESTY_IMAGE_BASE=ubuntu|centos|rhel -RESTY_IMAGE_TAG=trusty|xenial|6|7 +RESTY_IMAGE_BASE=ubuntu|centos|rhel|alpine +RESTY_IMAGE_TAG=trusty|xenial|6|7|latest ``` For RedHat additionally export: diff --git a/entrypoint.sh b/entrypoint.sh index 8560cf890254..9e517df5aa18 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,10 +16,16 @@ pushd /tmp/openssl popd pushd /kong - /tmp/build/usr/local/bin/luarocks make kong-*.rockspec \ + ROCKSPEC_VERSION=`basename $TMP/kong/kong-*.rockspec` \ + && ROCKSPEC_VERSION=${ROCKSPEC_VERSION%.*} \ + && ROCKSPEC_VERSION=${ROCKSPEC_VERSION#"kong-"} + + /tmp/build/usr/local/bin/luarocks make kong-${ROCKSPEC_VERSION}.rockspec \ OPENSSL_INCDIR=/tmp/openssl/include \ CRYPTO_INCDIR=/tmp/openssl/include \ CRYPTO_LIBDIR=/tmp/openssl + + cp kong.conf.default /tmp/build/usr/local/lib/luarocks/rocks/kong/$ROCKSPEC_VERSION/kong.conf.default popd cp /kong/bin/kong /tmp/build/usr/local/bin/kong diff --git a/fpm-entrypoint.sh b/fpm-entrypoint.sh index 11041262c894..635ff0f251e7 100755 --- a/fpm-entrypoint.sh +++ b/fpm-entrypoint.sh @@ -20,7 +20,14 @@ elif [ "$RESTY_IMAGE_BASE" == "rhel" ]; then fi fi -fpm -a all -f -s dir \ +if [ "$RESTY_IMAGE_BASE" == "alpine" ]; then + pushd /tmp/build + mkdir -p etc/kong + mv usr/local/lib/luarocks/rocks/kong/*/kong.conf.default etc/kong + tar -zcvf /output/${KONG_PACKAGE_NAME}-${KONG_VERSION}${OUTPUT_FILE_SUFFIX}.apk.tar.gz usr etc + popd +else + fpm -a all -f -s dir \ -t $PACKAGE_TYPE \ -m 'support@konghq.com' \ -n $KONG_PACKAGE_NAME \ @@ -31,6 +38,7 @@ fpm -a all -f -s dir \ --vendor 'Kong Inc.' \ --license "$KONG_LICENSE" \ --url 'https://getkong.org/' usr \ - && mv kong*.* /output/${KONG_PACKAGE_NAME}-${KONG_VERSION}${OUTPUT_FILE_SUFFIX}.${PACKAGE_TYPE} \ - && rm -rf /tmp/build/* - + && mv kong*.* /output/${KONG_PACKAGE_NAME}-${KONG_VERSION}${OUTPUT_FILE_SUFFIX}.${PACKAGE_TYPE} +fi + +rm -rf /tmp/build/*