Skip to content

Commit

Permalink
feat(dockerfiles): move our dockerfiles refs: #FT-2144 (#439)
Browse files Browse the repository at this point in the history
* feat(dockerfiles): move our dockerfiles

* chore(revert): swap to official settings

* chore(ci): add xenial back-in

* fix(amazonlinux): we need to nuke two lines so we can test amazonlinux assets

* fix(rpm): move the rpm hack into the docker-kong repository

* fix(centos8): substitute rockylinux:8 for centos:8 when doing user validation testing

* Update Makefile
  • Loading branch information
hutchic authored Feb 4, 2022
1 parent 0708ee4 commit 1efda44
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 143 deletions.
59 changes: 20 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,39 +145,19 @@ else ifeq ($(BUILDX),true)
-docker-machine rm --force ${DOCKER_MACHINE_ARM64_NAME}
endif

build-base:
docker pull centos:8
docker tag centos:8 centos:7
docker pull debian:9
docker tag debian:9 debian:8
ifeq ($(RESTY_IMAGE_BASE),src)
@echo "nothing to be done"
else ifeq ($(RESTY_IMAGE_BASE),rhel)
docker pull centos:${RESTY_IMAGE_TAG}
docker tag centos:${RESTY_IMAGE_TAG} rhel:${RESTY_IMAGE_TAG}
PACKAGE_TYPE=rpm
endif
$(CACHE_COMMAND) $(DOCKER_REPOSITORY):$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_BASE_SUFFIX) || \
( $(DOCKER_COMMAND) -f dockerfiles/Dockerfile.$(PACKAGE_TYPE) \
--build-arg RESTY_IMAGE_TAG="$(RESTY_IMAGE_TAG)" \
--build-arg RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \
-t $(DOCKER_REPOSITORY):$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_BASE_SUFFIX) . )

build-openresty:
ifeq ($(RESTY_IMAGE_BASE),src)
@echo "nothing to be done"
else
-rm -rf kong
-cp -R $(KONG_SOURCE_LOCATION) kong
$(CACHE_COMMAND) $(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_OPENRESTY_SUFFIX) || \
( $(MAKE) build-base ; \
$(DOCKER_COMMAND) -f dockerfiles/Dockerfile.openresty \
$(CACHE_COMMAND) $(DOCKER_REPOSITORY):openresty-$(PACKAGE_TYPE)-$(DOCKER_OPENRESTY_SUFFIX) || \
( $(DOCKER_COMMAND) -f dockerfiles/Dockerfile.openresty \
--build-arg RESTY_VERSION=$(RESTY_VERSION) \
--build-arg RESTY_LUAROCKS_VERSION=$(RESTY_LUAROCKS_VERSION) \
--build-arg RESTY_OPENSSL_VERSION=$(RESTY_OPENSSL_VERSION) \
--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 PACKAGE_TYPE=$(PACKAGE_TYPE) \
--build-arg DOCKER_REPOSITORY=$(DOCKER_REPOSITORY) \
--build-arg DOCKER_BASE_SUFFIX=$(DOCKER_BASE_SUFFIX) \
--build-arg LIBYAML_VERSION=$(LIBYAML_VERSION) \
Expand All @@ -188,7 +168,7 @@ else
--build-arg RESTY_LMDB=$(RESTY_LMDB) \
--build-arg OPENRESTY_PATCHES=$(OPENRESTY_PATCHES) \
--build-arg DEBUG=$(DEBUG) \
-t $(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_OPENRESTY_SUFFIX) . )
-t $(DOCKER_REPOSITORY):openresty-$(PACKAGE_TYPE)-$(DOCKER_OPENRESTY_SUFFIX) . )
endif

ifeq ($(RESTY_IMAGE_BASE),src)
Expand All @@ -204,8 +184,9 @@ ifeq ($(DEBUG),1)
endif
make build-kong
@$(DOCKER_COMMAND) -f dockerfiles/Dockerfile.package \
--build-arg RESTY_IMAGE_TAG="$(RESTY_IMAGE_TAG)" \
--build-arg RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \
--build-arg RESTY_IMAGE_TAG=$(RESTY_IMAGE_TAG) \
--build-arg PACKAGE_TYPE=$(PACKAGE_TYPE) \
--build-arg DOCKER_REPOSITORY=$(DOCKER_REPOSITORY) \
--build-arg DOCKER_KONG_SUFFIX=$(DOCKER_KONG_SUFFIX) \
--build-arg KONG_SHA=$(KONG_SHA) \
Expand All @@ -215,17 +196,16 @@ endif
--build-arg KONG_CONFLICTS=$(KONG_CONFLICTS) \
--build-arg PRIVATE_KEY_FILE=kong.private.gpg-key.asc \
--build-arg PRIVATE_KEY_PASSPHRASE="$(PRIVATE_KEY_PASSPHRASE)" \
-t $(DOCKER_REPOSITORY):kong-packaged-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_KONG_SUFFIX) .
-t $(DOCKER_REPOSITORY):kong-packaged-$(PACKAGE_TYPE)-$(DOCKER_KONG_SUFFIX) .
ifeq ($(BUILDX),false)
docker run -d --rm --name output $(DOCKER_REPOSITORY):kong-packaged-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_KONG_SUFFIX) tail -f /dev/null
docker run -d --rm --name output $(DOCKER_REPOSITORY):kong-packaged-$(PACKAGE_TYPE)-$(DOCKER_KONG_SUFFIX) tail -f /dev/null
docker cp output:/output/ output
docker stop output
mv output/output/*.$(PACKAGE_TYPE)* output/
rm -rf output/*/
else
docker buildx build --output output --platform linux/amd64,linux/arm64 -f dockerfiles/Dockerfile.scratch \
--build-arg RESTY_IMAGE_TAG="$(RESTY_IMAGE_TAG)" \
--build-arg RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \
--build-arg PACKAGE_TYPE=$(PACKAGE_TYPE) \
--build-arg DOCKER_REPOSITORY=$(DOCKER_REPOSITORY) \
--build-arg DOCKER_KONG_SUFFIX=$(DOCKER_KONG_SUFFIX) \
--build-arg KONG_SHA=$(KONG_SHA) .
Expand All @@ -244,22 +224,21 @@ actual-build-kong:
touch id_rsa.private
-rm -rf kong
-cp -R $(KONG_SOURCE_LOCATION) kong
$(CACHE_COMMAND) $(DOCKER_REPOSITORY):kong-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_KONG_SUFFIX) || \
$(CACHE_COMMAND) $(DOCKER_REPOSITORY):kong-$(PACKAGE_TYPE)-$(DOCKER_KONG_SUFFIX) || \
( $(MAKE) build-openresty && \
$(DOCKER_COMMAND) -f dockerfiles/Dockerfile.kong \
--build-arg RESTY_IMAGE_TAG="$(RESTY_IMAGE_TAG)" \
--build-arg RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \
--build-arg PACKAGE_TYPE=$(PACKAGE_TYPE) \
--build-arg DOCKER_REPOSITORY=$(DOCKER_REPOSITORY) \
--build-arg DOCKER_OPENRESTY_SUFFIX=$(DOCKER_OPENRESTY_SUFFIX) \
-t $(DOCKER_REPOSITORY):kong-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_KONG_SUFFIX) . )
-t $(DOCKER_REPOSITORY):kong-$(PACKAGE_TYPE)-$(DOCKER_KONG_SUFFIX) . )

kong-test-container:
ifneq ($(RESTY_IMAGE_BASE),src)
-rm -rf kong
-cp -R $(KONG_SOURCE_LOCATION) kong
$(CACHE_COMMAND) $(DOCKER_REPOSITORY):test-$(DOCKER_TEST_SUFFIX) || \
( $(MAKE) build-openresty && \
docker tag $(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_OPENRESTY_SUFFIX) \
docker tag $(DOCKER_REPOSITORY):openresty-$(PACKAGE_TYPE)-$(DOCKER_OPENRESTY_SUFFIX) \
$(DOCKER_REPOSITORY):test-$(DOCKER_OPENRESTY_SUFFIX) && \
$(DOCKER_COMMAND) -f test/Dockerfile.test \
--build-arg KONG_GO_PLUGINSERVER_VERSION=$(KONG_GO_PLUGINSERVER_VERSION) \
Expand Down Expand Up @@ -359,6 +338,8 @@ ifneq ($(RESTY_IMAGE_BASE),src)
endif

build-test-container:
docker pull rockylinux:8
docker tag rockylinux:8 centos:8
touch test/kong_license.private
ARCHITECTURE=amd64 \
RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \
Expand Down Expand Up @@ -407,8 +388,8 @@ cleanup: cleanup-tests cleanup-build
-rm -rf output/*

update-cache-images:
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_BASE_SUFFIX)
-docker tag $(DOCKER_REPOSITORY):$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_BASE_SUFFIX) $(DOCKER_REPOSITORY):$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG) || true
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG) || true
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_OPENRESTY_SUFFIX)
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):kong-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_KONG_SUFFIX)
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):$(PACKAGE_TYPE)-$(DOCKER_BASE_SUFFIX)
-docker tag $(DOCKER_REPOSITORY):$(PACKAGE_TYPE)-$(DOCKER_BASE_SUFFIX) $(DOCKER_REPOSITORY):$(PACKAGE_TYPE) || true
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):$(PACKAGE_TYPE) || true
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):openresty-$(PACKAGE_TYPE)-$(DOCKER_OPENRESTY_SUFFIX)
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):kong-$(PACKAGE_TYPE)-$(DOCKER_KONG_SUFFIX)
6 changes: 4 additions & 2 deletions build-kong.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChec
export LUAROCKS_CONFIG=$ROCKS_CONFIG
export LUA_PATH="/usr/local/share/lua/5.1/?.lua;/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/?.lua;;"
export PATH=$PATH:/usr/local/openresty/luajit/bin

cp -R /tmp/build/* /

/usr/local/bin/luarocks --version
/usr/local/kong/bin/openssl version
/usr/local/openresty/bin/openresty -v

if test -f /root/id_rsa; then
mkdir -p /root/.ssh
Expand Down
16 changes: 0 additions & 16 deletions dockerfiles/Dockerfile.apk

This file was deleted.

44 changes: 0 additions & 44 deletions dockerfiles/Dockerfile.deb

This file was deleted.

5 changes: 2 additions & 3 deletions dockerfiles/Dockerfile.kong
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
ARG RESTY_IMAGE_BASE="ubuntu"
ARG RESTY_IMAGE_TAG="20.04"
ARG PACKAGE_TYPE
ARG DOCKER_OPENRESTY_SUFFIX
ARG DOCKER_REPOSITORY

FROM ${DOCKER_REPOSITORY}:openresty-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG}-${DOCKER_OPENRESTY_SUFFIX}
FROM ${DOCKER_REPOSITORY}:openresty-${PACKAGE_TYPE}-${DOCKER_OPENRESTY_SUFFIX}

WORKDIR /kong
COPY kong /kong
Expand Down
5 changes: 2 additions & 3 deletions dockerfiles/Dockerfile.openresty
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
ARG RESTY_IMAGE_BASE="ubuntu"
ARG RESTY_IMAGE_TAG="20.04"
ARG DOCKER_BASE_SUFFIX
ARG DOCKER_REPOSITORY
ARG PACKAGE_TYPE

FROM ${DOCKER_REPOSITORY}:${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG}-${DOCKER_BASE_SUFFIX}
FROM kong/kong-build-tools:$PACKAGE_TYPE

ARG EDITION="community"
ENV EDITION $EDITION
Expand Down
6 changes: 3 additions & 3 deletions dockerfiles/Dockerfile.package
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
ARG RESTY_IMAGE_BASE="ubuntu"
ARG RESTY_IMAGE_TAG="20.04"
ARG PACKAGE_TYPE
ARG DOCKER_KONG_SUFFIX
ARG KONG_SHA
ARG DOCKER_REPOSITORY

FROM ${DOCKER_REPOSITORY}:kong-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG}-${DOCKER_KONG_SUFFIX} as KONG
FROM ${DOCKER_REPOSITORY}:kong-${PACKAGE_TYPE}-${DOCKER_KONG_SUFFIX} as KONG

FROM kong/fpm:latest as FPM

Expand All @@ -19,6 +18,7 @@ ENV PRIVATE_KEY_PASSPHRASE ${PRIVATE_KEY_PASSPHRASE}

ARG RESTY_IMAGE_BASE="ubuntu"
ARG RESTY_IMAGE_TAG="16.04"
ARG PACKAGE_TYPE
ARG KONG_VERSION
ARG KONG_PACKAGE_NAME
ARG KONG_CONFLICTS
Expand Down
24 changes: 0 additions & 24 deletions dockerfiles/Dockerfile.rpm

This file was deleted.

5 changes: 2 additions & 3 deletions dockerfiles/Dockerfile.scratch
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
ARG RESTY_IMAGE_BASE="ubuntu"
ARG RESTY_IMAGE_TAG="16.04"
ARG PACKAGE_TYPE
ARG DOCKER_KONG_SUFFIX
ARG KONG_SHA
ARG DOCKER_REPOSITORY

FROM --platform=$TARGETPLATFORM ${DOCKER_REPOSITORY}:kong-packaged-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG}-${DOCKER_KONG_SUFFIX} as FPM
FROM --platform=$TARGETPLATFORM ${DOCKER_REPOSITORY}:kong-packaged-${PACKAGE_TYPE}-${DOCKER_KONG_SUFFIX} as FPM

FROM --platform=$TARGETPLATFORM scratch

Expand Down
8 changes: 3 additions & 5 deletions fpm-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ set -o errexit
cd /tmp/build

FPM_PARAMS=""
if [ "$RESTY_IMAGE_BASE" == "ubuntu" ] || [ "$RESTY_IMAGE_BASE" == "debian" ]; then
PACKAGE_TYPE="deb"
if [ "$PACKAGE_TYPE" == "deb" ]; then
FPM_PARAMS="-d libpcre3 -d perl -d zlib1g-dev"
OUTPUT_FILE_SUFFIX=".${RESTY_IMAGE_TAG}"
elif [ "$RESTY_IMAGE_BASE" == "centos" ] || [ "$RESTY_IMAGE_BASE" == "rhel" ] || [ "$RESTY_IMAGE_BASE" == "amazonlinux" ]; then
PACKAGE_TYPE="rpm"
elif [ "$PACKAGE_TYPE" == "rpm" ]; then
FPM_PARAMS="-d pcre -d perl -d perl-Time-HiRes -d zlib -d zlib-devel"
OUTPUT_FILE_SUFFIX=".rhel${RESTY_IMAGE_TAG}"
if [ "$RESTY_IMAGE_TAG" == "7" ]; then
Expand All @@ -28,7 +26,7 @@ OUTPUT_FILE_SUFFIX="${OUTPUT_FILE_SUFFIX}."$(echo ${BUILDPLATFORM} | awk -F "/"

ROCKSPEC_VERSION=`basename /tmp/build/build/usr/local/lib/luarocks/rocks/kong/*`

if [ "$RESTY_IMAGE_BASE" == "alpine" ]; then
if [ "$PACKAGE_TYPE" == "apk" ]; then
pushd /tmp/build
mkdir /output
tar -zcvf /output/${KONG_PACKAGE_NAME}-${KONG_VERSION}${OUTPUT_FILE_SUFFIX}.apk.tar.gz usr etc
Expand Down
2 changes: 1 addition & 1 deletion test/tests/01-package/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi

if [[ "$PACKAGE_TYPE" == "rpm" ]]; then
cp $PACKAGE_LOCATION/*amd64.rpm kong.rpm
docker exec ${USE_TTY} user-validation-tests /bin/bash -c "yum install -y /src/kong.rpm"
docker exec ${USE_TTY} user-validation-tests /bin/bash -c "yum install -y /src/kong.rpm procps"
docker exec ${USE_TTY} user-validation-tests /bin/bash -c "kong version"
# Tests disabled until CSRE-467 is resolved
# docker exec ${USE_TTY} user-validation-tests /bin/bash -c "rpm --import https://download.konghq.com/gateway-2.x-rhel-8/repodata/repomd.xml.key"
Expand Down

0 comments on commit 1efda44

Please sign in to comment.