Skip to content

Commit

Permalink
feat(alpine) build and package Kong for docker alpine (#6)
Browse files Browse the repository at this point in the history
* feat(RHEL) add the ability to build RHEL rpm packages

* feat(rhel) setup rhel package naming

* feat(rhel) setup release scripts for RHEL

* misc(docs) Update the readme to detail RHEL and releasing to bintray

* feat(centos) ability to release centos to bintray

* feat(alpine) alpine openssl needs no-async

* feat(alpine) setup packaging the alpine tar.gz
  • Loading branch information
hutchic authored Nov 8, 2018
1 parent 2b3c5b4 commit 6364ca9
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 21 deletions.
13 changes: 13 additions & 0 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -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

7 changes: 3 additions & 4 deletions Dockerfile.openresty
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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} \
Expand Down
22 changes: 12 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 \
Expand All @@ -68,23 +71,22 @@ 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 \
--build-arg RHEL=true \
--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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions fpm-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 '[email protected]' \
-n $KONG_PACKAGE_NAME \
Expand All @@ -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/*

0 comments on commit 6364ca9

Please sign in to comment.