Skip to content

Commit

Permalink
release/2.0.4 (Kong#361)
Browse files Browse the repository at this point in the history
* fix(builds) adjust our Dockerfiles so they are conformant with official docker image builder

* chore(release) bump to 2.0.4

* chore(build) dont COPY based on a ARG for the official docker image build compatibility

* fix(commands) squash some of the RUN commands together

* chore(combine) combine some RUN commands

* fix(curl) add -f to the curl command so they fail if the asset isn't found

* chore(automation) update the update.sh script to be compatible with the new Dockerfile's

* chore(redhat) update redhat to be more easily updated automatically

* fix(update) adjust so the update script is ubuntu compatible

* chore(readme) we dont require the previous version

* fix(local) adjust buildling with local asset
  • Loading branch information
hutchic authored May 6, 2020
1 parent dbc225c commit ac9748b
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 156 deletions.
47 changes: 22 additions & 25 deletions alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,35 @@ FROM alpine:3.11

LABEL maintainer="Kong <support@konghq.com>"

ARG BINTRAY_USER
ENV BINTRAY_USER $BINTRAY_USER
ARG ASSET=ce
ENV ASSET $ASSET

ARG BINTRAY_KEY
ENV BINTRAY_KEY $BINTRAY_KEY
COPY empty-kong.tar.gz /tmp/kong.tar.gz

ARG BUILD_SCRIPT=build-ce.sh
COPY $BUILD_SCRIPT /tmp/build.sh
ARG KONG_VERSION=2.0.4
ENV KONG_VERSION $KONG_VERSION

ARG ASSET_LOCATION=bintray
ENV ASSET_LOCATION $ASSET_LOCATION
ARG KONG_SHA256="457dd0172ae2de2e0b71ce625f78e06449faf38fd734dd6825eb7782d74cb77e"
ENV KONG_SHA256 $KONG_SHA256

ARG LOCAL_KONG_PACKAGE=empty-kong.tar.gz
COPY $LOCAL_KONG_PACKAGE /tmp/kong.tar.gz

RUN if [ "$ASSET_LOCATION" = "local" ] ; then exit 0 ; fi; \
apk add --no-cache --virtual .build-deps curl wget tar ca-certificates && \
. /tmp/build.sh && \
apk del .build-deps

RUN mkdir /kong; \
RUN set -ex; \
if [ "$ASSET" = "ce" ] ; then \
apk add --no-cache --virtual .build-deps curl wget tar ca-certificates && \
curl -fL "https://bintray.com/kong/kong-alpine-tar/download_file?file_path=kong-$KONG_VERSION.amd64.apk.tar.gz" -o /tmp/kong.tar.gz && \
echo "$KONG_SHA256 /tmp/kong.tar.gz" | sha256sum -c -; \
apk del .build-deps; \
fi; \
mkdir /kong; \
tar -C /kong -xzf /tmp/kong.tar.gz && \
mv /kong/usr/local/* /usr/local && \
mv /kong/etc/* /etc && \
rm -rf /kong

RUN apk add --no-cache libgcc openssl pcre perl tzdata libcap zip bash zlib \
&& adduser -S kong \
&& mkdir -p "/usr/local/kong" \
&& chown -R kong:0 /usr/local/kong \
&& chown kong:0 /usr/local/bin/kong \
&& chmod -R g=u /usr/local/kong
rm -rf /kong && \
apk add --no-cache libgcc openssl pcre perl tzdata libcap zip bash zlib && \
adduser -S kong && \
mkdir -p "/usr/local/kong" && \
chown -R kong:0 /usr/local/kong && \
chown kong:0 /usr/local/bin/kong && \
chmod -R g=u /usr/local/kong

COPY docker-entrypoint.sh /docker-entrypoint.sh

Expand Down
3 changes: 0 additions & 3 deletions alpine/build-ce.sh

This file was deleted.

2 changes: 0 additions & 2 deletions alpine/build-ee.sh

This file was deleted.

37 changes: 16 additions & 21 deletions centos/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
ARG RESTY_IMAGE_BASE="centos"
ARG RESTY_IMAGE_TAG="7"
FROM ${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG}
FROM centos:7
LABEL maintainer="Kong <support@konghq.com>"

ARG BINTRAY_USER
ENV BINTRAY_USER $BINTRAY_USER
ARG ASSET=ce
ENV ASSET $ASSET

ARG BINTRAY_KEY
ENV BINTRAY_KEY $BINTRAY_KEY
COPY empty-kong.rpm /tmp/kong.rpm

ARG BUILD_SCRIPT=build-ce.sh
COPY $BUILD_SCRIPT /tmp/build.sh
ARG KONG_VERSION=2.0.4
ENV KONG_VERSION $KONG_VERSION

ARG ASSET_LOCATION=bintray
ENV ASSET_LOCATION $ASSET_LOCATION
ARG KONG_SHA256="16a934a7bc2e182f00f03bd75b67f4bdb483150b3820d33cab9b0c95539dd353"
ENV KONG_SHA256 $KONG_SHA256

ARG LOCAL_KONG_PACKAGE=empty-kong.rpm
COPY $LOCAL_KONG_PACKAGE /tmp/kong.rpm

RUN if [ "$ASSET_LOCATION" = "local" ] ; then exit 0 ; fi; \
. /tmp/build.sh

RUN yum install -y -q unzip shadow-utils zlib \
RUN set -ex; \
if [ "$ASSET" = "ce" ] ; then \
curl -fL "https://bintray.com/kong/kong-rpm/download_file?file_path=centos/7/kong-$KONG_VERSION.el7.amd64.rpm" -o /tmp/kong.rpm \
&& echo "$KONG_SHA256 /tmp/kong.rpm" | sha256sum -c -; \
fi; \
yum install -y -q unzip shadow-utils \
&& yum clean all -q \
&& rm -fr /var/cache/yum/* /tmp/yum_save*.yumtx /root/.pki

RUN useradd kong \
&& rm -fr /var/cache/yum/* /tmp/yum_save*.yumtx /root/.pki \
&& useradd kong \
&& mkdir -p "/usr/local/kong" \
&& yum install -y /tmp/kong.rpm \
&& yum clean all \
Expand Down
3 changes: 0 additions & 3 deletions centos/build-ce.sh

This file was deleted.

3 changes: 0 additions & 3 deletions centos/build-ee.sh

This file was deleted.

52 changes: 21 additions & 31 deletions rhel/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,4 @@
ARG RESTY_IMAGE_TAG="7"
FROM ubuntu:bionic AS downloader

RUN apt-get update \
&& apt-get install -y curl

ARG BINTRAY_USER
ENV BINTRAY_USER $BINTRAY_USER

ARG BINTRAY_KEY
ENV BINTRAY_KEY $BINTRAY_KEY

ARG BUILD_SCRIPT=build-ce.sh
COPY $BUILD_SCRIPT /tmp/build.sh

ARG ASSET_LOCATION=bintray
ENV ASSET_LOCATION $ASSET_LOCATION

ARG LOCAL_KONG_PACKAGE=empty-kong.rpm
COPY $LOCAL_KONG_PACKAGE /tmp/kong.rpm

RUN if [ "$ASSET_LOCATION" = "local" ] ; then exit 0 ; fi; \
. /tmp/build.sh

FROM registry.access.redhat.com/ubi${RESTY_IMAGE_TAG}/ubi
FROM registry.access.redhat.com/ubi7/ubi

MAINTAINER Kong

Expand All @@ -34,14 +10,28 @@ LABEL name="Kong" \
summary="Next-Generation API Platform for Modern Architectures" \
description="Next-Generation API Platform for Modern Architectures"

COPY --from=downloader /tmp/kong.rpm /tmp/kong.rpm
COPY LICENSE /licenses/

RUN yum install -y -q unzip zlib \
&& yum clean all -q \
&& rm -fr /var/cache/yum/* /tmp/yum_save*.yumtx /root/.pki
ARG ASSET=ce
ENV ASSET $ASSET

COPY empty-kong.rpm /tmp/kong.rpm

RUN useradd kong \
ARG KONG_VERSION=2.0.4
ENV KONG_VERSION $KONG_VERSION

ARG KONG_SHA256="74651c62e1d22fc4fa27354527f5a9b080b9866991d0cec6d2fdd5322c586c4e"
ENV KONG_SHA256 $KONG_SHA256

RUN set -ex; \
if [ "$ASSET" = "ce" ] ; then \
curl -fL "https://bintray.com/kong/kong-rpm/download_file?file_path=rhel/7/kong-$KONG_VERSION.rhel7.amd64.rpm" -o /tmp/kong.rpm \
&& echo "$KONG_SHA256 /tmp/kong.rpm" | sha256sum -c -; \
fi; \
yum install -y -q unzip shadow-utils \
&& yum clean all -q \
&& rm -fr /var/cache/yum/* /tmp/yum_save*.yumtx /root/.pki \
&& useradd kong \
&& mkdir -p "/usr/local/kong" \
&& yum install -y /tmp/kong.rpm \
&& yum clean all \
Expand All @@ -60,4 +50,4 @@ EXPOSE 8000 8443 8001 8444

STOPSIGNAL SIGQUIT

CMD ["kong", "docker-start"]
CMD ["kong", "docker-start"]
3 changes: 0 additions & 3 deletions rhel/build-ce.sh

This file was deleted.

3 changes: 0 additions & 3 deletions rhel/build-ee.sh

This file was deleted.

2 changes: 1 addition & 1 deletion tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -ex

# Test the proper version was buid
pushd $BASE
version_given="$(grep -o -P '(?<=-).*(?=})' build-ce.sh)"
version_given="$(grep 'ARG KONG_VERSION' Dockerfile | awk -F "=" '{print $2}')"
version_built="$(docker run -ti --rm kong-$BASE kong version | tr -d '[:space:]')"

if [[ "$version_given" != "$version_built" ]]; then
Expand Down
39 changes: 15 additions & 24 deletions ubuntu/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
ARG RESTY_IMAGE_BASE="ubuntu"
ARG RESTY_IMAGE_TAG="xenial"
FROM ${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG}
FROM ubuntu:xenial

ARG BINTRAY_USER
ENV BINTRAY_USER $BINTRAY_USER
ARG ASSET=ce
ENV ASSET $ASSET

ARG BINTRAY_KEY
ENV BINTRAY_KEY $BINTRAY_KEY
COPY empty-kong.deb /tmp/kong.deb

ARG BUILD_SCRIPT=build-ce.sh
COPY $BUILD_SCRIPT /tmp/build.sh
ARG KONG_VERSION=2.0.4
ENV KONG_VERSION $KONG_VERSION

ARG ASSET_LOCATION=bintray
ENV ASSET_LOCATION $ASSET_LOCATION

ARG LOCAL_KONG_PACKAGE=empty-kong.deb
COPY $LOCAL_KONG_PACKAGE /tmp/kong.deb

RUN if [ "$ASSET_LOCATION" = "local" ] ; then exit 0 ; fi; \
RUN set -ex; \
if [ "$ASSET" = "ce" ] ; then \
apt-get update && \
apt-get install -y curl && \
curl -fL "https://bintray.com/kong/kong-deb/download_file?file_path=kong-$KONG_VERSION.xenial.$(dpkg --print-architecture).deb" -o /tmp/kong.deb \
&& apt-get purge -y curl; \
fi; \
apt-get update \
&& apt-get install -y curl && \
. /tmp/build.sh && \
apt-get purge -yf curl

RUN apt-get update \
&& apt-get install -y --no-install-recommends perl unzip \
&& apt-get install -y --no-install-recommends zlibc || true \
&& apt-get install -y --no-install-recommends zlib1g-dev || true \
&& rm -rf /var/lib/apt/lists/* \
&& dpkg -i /tmp/kong.deb \
&& rm -rf /tmp/kong.deb

RUN useradd -ms /bin/bash kong \
&& rm -rf /tmp/kong.deb \
&& useradd -ms /bin/bash kong \
&& mkdir -p "/usr/local/kong" \
&& chown -R kong:0 /usr/local/kong \
&& chown kong:0 /usr/local/bin/kong \
Expand Down
2 changes: 0 additions & 2 deletions ubuntu/build-ce.sh

This file was deleted.

55 changes: 20 additions & 35 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ set -e

if ! [ "$1" ]
then
echo "usage: $0 <version> [<prev_tag>]"
echo "example: $0 1.2.3 1.2.2"
echo "usage: $0 <version>"
echo "example: $0 1.2.3"
exit 1
fi

version=$1
prev_tag=$2

if [ "$prev_tag" = "" ]
then
prev_tag=master
fi

function red() {
echo -e "\033[1;31m$@\033[0m"
Expand All @@ -30,44 +24,35 @@ function die() {
hub --version &> /dev/null || die "hub is not in PATH. Get it from https://github.com/github/hub"

pushd alpine
./build-ce.sh
mv /tmp/kong.tar.gz /tmp/kong.tar.gz.old
old_sha=$(sha256sum /tmp/kong.tar.gz.old | cut -b1-64)
VERSION=$version ./build-ce.sh || true
mv /tmp/kong.tar.gz /tmp/kong.tar.gz.new
new_sha=$(sha256sum /tmp/kong.tar.gz.new | cut -b1-64)
url=$(grep bintray.com Dockerfile | awk -F" " '{print $3}' | sed 's/\"//g' | sed 's/$KONG_VERSION/'$version'/g')
curl -fL $url -o /tmp/kong
new_sha=$(sha256sum /tmp/kong | cut -b1-64)

sed -i -e 's/'$old_sha'/'$new_sha'/g' build-ce.sh
rm /tmp/kong.tar.gz.*
sed -i -e 's/ARG KONG_SHA256=.*/ARG KONG_SHA256=\"'$new_sha'\"/g' Dockerfile
sed -i -e 's/ARG KONG_VERSION=.*/ARG KONG_VERSION='$version'/g' Dockerfile
popd

pushd centos
./build-ce.sh
mv /tmp/kong.rpm /tmp/kong.rpm.old
old_sha=$(sha256sum /tmp/kong.rpm.old | cut -b1-64)
VERSION=$version ./build-ce.sh || true
mv /tmp/kong.rpm /tmp/kong.rpm.new
new_sha=$(sha256sum /tmp/kong.rpm.new | cut -b1-64)
url=$(grep bintray.com Dockerfile | awk -F" " '{print $3}' | sed 's/\"//g' | sed 's/$KONG_VERSION/'$version'/g')
curl -fL $url -o /tmp/kong
new_sha=$(sha256sum /tmp/kong | cut -b1-64)

sed -i -e 's/'$old_sha'/'$new_sha'/g' build-ce.sh
rm /tmp/kong.rpm.*
sed -i -e 's/ARG KONG_SHA256=.*/ARG KONG_SHA256=\"'$new_sha'\"/g' Dockerfile
sed -i -e 's/ARG KONG_VERSION=.*/ARG KONG_VERSION='$version'/g' Dockerfile
popd

pushd rhel
./build-ce.sh
mv /tmp/kong.rpm /tmp/kong.rpm.old
old_sha=$(sha256sum /tmp/kong.rpm.old | cut -b1-64)
VERSION=$version ./build-ce.sh || true
mv /tmp/kong.rpm /tmp/kong.rpm.new
new_sha=$(sha256sum /tmp/kong.rpm.new | cut -b1-64)
url=$(grep bintray.com Dockerfile | awk -F" " '{print $3}' | sed 's/\"//g' | sed 's/$KONG_VERSION/'$version'/g')
curl -fL $url -o /tmp/kong
new_sha=$(sha256sum /tmp/kong | cut -b1-64)

sed -i -e 's/'$old_sha'/'$new_sha'/g' build-ce.sh
sed -i -e "s/$prev_tag/$version/" Dockerfile

rm /tmp/kong.rpm.*
sed -i -e 's/ARG KONG_SHA256=.*/ARG KONG_SHA256=\"'$new_sha'\"/g' Dockerfile
sed -i -e 's/ARG KONG_VERSION=.*/ARG KONG_VERSION='$version'/g' Dockerfile
popd

sed -i -e "s/$prev_tag/$version/" */build-ce.sh
pushd ubuntu
sed -i -e 's/ARG KONG_VERSION=.*/ARG KONG_VERSION='$version'/g' Dockerfile
popd

echo "****************************************"
git diff
Expand Down

0 comments on commit ac9748b

Please sign in to comment.