Skip to content

Commit

Permalink
chore(*) do not bundled go-pluginserver with kong builds (#299)
Browse files Browse the repository at this point in the history
go-pluginserver was included in 2.0 along with Kong distributions. However, as it carries strict requirements of Go compiler version and go-pdk, it ended up not being of much value, since users would be required to recompile it with the same go-pdk and Go compiler as their plugins. It was then decided to remove it, and instead provide guides/examples of how to easily build pluginserver from sources.
  • Loading branch information
gszr authored Jun 24, 2020
1 parent 3ddbfb8 commit ab02bf9
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 177 deletions.
27 changes: 0 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ KONG_SHA=$$(git --git-dir=$(KONG_SOURCE_LOCATION)/.git rev-parse --short HEAD)

DOCKER_BASE_SUFFIX=${BUILD_TOOLS_SHA}${CACHE_BUSTER}
DOCKER_OPENRESTY_SUFFIX=${BUILD_TOOLS_SHA}-${REQUIREMENTS_SHA}${OPENRESTY_PATCHES}${DEBUG}-${CACHE_BUSTER}
DOCKER_GO_SUFFIX=${BUILD_TOOLS_SHA}-${KONG_GO_PLUGINSERVER_VERSION}${CACHE_BUSTER}
DOCKER_KONG_SUFFIX=${BUILD_TOOLS_SHA}${OPENRESTY_PATCHES}${DEBUG}-${KONG_VERSION}-${KONG_SHA}-${CACHE_BUSTER}
DOCKER_TEST_SUFFIX=${BUILD_TOOLS_SHA}-${DEBUG}-${KONG_SHA}-${CACHE_BUSTER}
OFFICIAL_RELEASE?=false
Expand Down Expand Up @@ -153,21 +152,6 @@ endif
--build-arg RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \
-t $(DOCKER_REPOSITORY):$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_BASE_SUFFIX) . )

build-golang:
ifeq ($(RESTY_IMAGE_BASE),src)
@echo "nothing to be done"
else
$(CACHE_COMMAND) $(DOCKER_REPOSITORY):go-plugin-tool-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_GO_SUFFIX) || \
( $(MAKE) build-base ; \
$(DOCKER_COMMAND) -f dockerfiles/Dockerfile.golang \
--build-arg KONG_GO_PLUGINSERVER_VERSION=$(KONG_GO_PLUGINSERVER_VERSION) \
--build-arg RESTY_IMAGE_TAG="$(RESTY_IMAGE_TAG)" \
--build-arg RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \
--build-arg DOCKER_REPOSITORY=$(DOCKER_REPOSITORY) \
--build-arg DOCKER_BASE_SUFFIX=$(DOCKER_BASE_SUFFIX) \
-t $(DOCKER_REPOSITORY):go-plugin-tool-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_GO_SUFFIX) . )
endif

build-openresty:
ifeq ($(RESTY_IMAGE_BASE),src)
@echo "nothing to be done"
Expand All @@ -177,7 +161,6 @@ else
$(CACHE_COMMAND) $(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_OPENRESTY_SUFFIX) || \
( $(MAKE) build-base ; \
$(DOCKER_COMMAND) -f dockerfiles/Dockerfile.openresty \
--build-arg KONG_GO_PLUGINSERVER_VERSION=$(KONG_GO_PLUGINSERVER_VERSION) \
--build-arg RESTY_VERSION=$(RESTY_VERSION) \
--build-arg RESTY_LUAROCKS_VERSION=$(RESTY_LUAROCKS_VERSION) \
--build-arg RESTY_OPENSSL_VERSION=$(RESTY_OPENSSL_VERSION) \
Expand Down Expand Up @@ -251,13 +234,11 @@ actual-build-kong:
-cp -R $(KONG_SOURCE_LOCATION) kong
$(CACHE_COMMAND) $(DOCKER_REPOSITORY):kong-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_KONG_SUFFIX) || \
( $(MAKE) build-openresty && \
$(MAKE) build-golang && \
$(DOCKER_COMMAND) -f dockerfiles/Dockerfile.kong \
--build-arg RESTY_IMAGE_TAG="$(RESTY_IMAGE_TAG)" \
--build-arg RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \
--build-arg DOCKER_REPOSITORY=$(DOCKER_REPOSITORY) \
--build-arg DOCKER_OPENRESTY_SUFFIX=$(DOCKER_OPENRESTY_SUFFIX) \
--build-arg DOCKER_GO_SUFFIX=$(DOCKER_GO_SUFFIX) \
-t $(DOCKER_REPOSITORY):kong-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_KONG_SUFFIX) . )

kong-test-container:
Expand All @@ -269,8 +250,6 @@ ifneq ($(RESTY_IMAGE_BASE),src)
docker tag $(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_OPENRESTY_SUFFIX) \
$(DOCKER_REPOSITORY):test-$(DOCKER_OPENRESTY_SUFFIX) )

$(MAKE) build-golang

docker run -d --rm --name test $(DOCKER_REPOSITORY):test-$(DOCKER_OPENRESTY_SUFFIX) tail -f /dev/null
docker export test | docker import - $(DOCKER_REPOSITORY):test-$(DOCKER_OPENRESTY_SUFFIX)
docker stop test
Expand All @@ -279,7 +258,6 @@ ifneq ($(RESTY_IMAGE_BASE),src)
--build-arg KONG_GO_PLUGINSERVER_VERSION=$(KONG_GO_PLUGINSERVER_VERSION) \
--build-arg DOCKER_REPOSITORY=$(DOCKER_REPOSITORY) \
--build-arg DOCKER_OPENRESTY_SUFFIX=$(DOCKER_OPENRESTY_SUFFIX) \
--build-arg DOCKER_GO_SUFFIX=$(DOCKER_GO_SUFFIX) \
-t $(DOCKER_REPOSITORY):test-$(DOCKER_TEST_SUFFIX) .
docker tag $(DOCKER_REPOSITORY):test-$(DOCKER_TEST_SUFFIX) $(DOCKER_REPOSITORY):test
docker tag $(DOCKER_REPOSITORY):test-$(DOCKER_TEST_SUFFIX) $(DOCKER_REPOSITORY):test-$(DOCKER_OPENRESTY_SUFFIX)
Expand All @@ -296,7 +274,6 @@ release-kong: test
ARCHITECTURE=amd64 \
RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \
RESTY_IMAGE_TAG=$(RESTY_IMAGE_TAG) \
DOCKER_GO_SUFFIX=$(DOCKER_GO_SUFFIX) \
KONG_PACKAGE_NAME=$(KONG_PACKAGE_NAME) \
KONG_VERSION=$(KONG_VERSION) \
BINTRAY_USR=$(BINTRAY_USR) \
Expand All @@ -309,13 +286,11 @@ ifeq ($(BUILDX),true)
@ARCHITECTURE=arm64 \
RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \
RESTY_IMAGE_TAG=$(RESTY_IMAGE_TAG) \
DOCKER_GO_SUFFIX=$(DOCKER_GO_SUFFIX) \
KONG_PACKAGE_NAME=$(KONG_PACKAGE_NAME) \
KONG_VERSION=$(KONG_VERSION) \
BINTRAY_USR=$(BINTRAY_USR) \
BINTRAY_KEY=$(BINTRAY_KEY) \
PRIVATE_REPOSITORY=$(PRIVATE_REPOSITORY) \
DOCKER_GO_SUFFIX=$(DOCKER_GO_SUFFIX) \
RELEASE_DOCKER_ONLY=$(RELEASE_DOCKER_ONLY) \
OFFICIAL_RELEASE=$(OFFICIAL_RELEASE) \
./release-kong.sh
Expand Down Expand Up @@ -347,7 +322,6 @@ ifneq ($(RESTY_IMAGE_BASE),src)
KONG_PROXY_URI="http://$(TEST_HOST):$(TEST_PROXY_PORT)" \
TEST_COMPOSE_PATH=$(TEST_COMPOSE_PATH) \
KONG_GO_PLUGINSERVER_VERSION=$(KONG_GO_PLUGINSERVER_VERSION) \
DOCKER_GO_BUILDER=$(DOCKER_REPOSITORY):go-plugin-tool-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_GO_SUFFIX) \
./test/run_tests.sh && make update-cache-images
endif

Expand Down Expand Up @@ -397,5 +371,4 @@ cleanup: cleanup-tests cleanup-build
update-cache-images:
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_BASE_SUFFIX)
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_OPENRESTY_SUFFIX)
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):go-plugin-tool-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_GO_SUFFIX)
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):kong-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_KONG_SUFFIX)
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ Also does some rudimentary checks of the systemd and logrotate we include with o
Uses the python [tavern](https://taverntesting.github.io/) testing tool to run functional tests against Kong with Postgres by
sending REST requests to the Kong admin api and validating the expected responses / behaviour on the proxy ports.

**03-go-plugin**

Builds a go-plugin and sets it up with Kong to verify the go-plugin capabilities

## Releasing Kong

The same defaults that applied when creating a packaged version of Kong apply to releasing said package
Expand Down
60 changes: 0 additions & 60 deletions dockerfiles/Dockerfile.golang

This file was deleted.

5 changes: 0 additions & 5 deletions dockerfiles/Dockerfile.kong
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
ARG RESTY_IMAGE_BASE="ubuntu"
ARG RESTY_IMAGE_TAG="bionic"
ARG DOCKER_OPENRESTY_SUFFIX
ARG DOCKER_GO_SUFFIX
ARG DOCKER_REPOSITORY

FROM ${DOCKER_REPOSITORY}:go-plugin-tool-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG}-${DOCKER_GO_SUFFIX} as GOLANG

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

WORKDIR /kong
Expand All @@ -14,5 +11,3 @@ COPY id_rsa /root/id_rsa
COPY build-kong.sh /build-kong.sh

RUN /build-kong.sh

COPY --from=GOLANG /usr/local/bin/go-pluginserver /tmp/build/usr/local/bin/go-pluginserver
12 changes: 0 additions & 12 deletions release-kong.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ if [ "$REPOSITORY_OS_NAME" == "next" ]; then
DOCKER_TAG="development"
fi

if [ "$OFFICIAL_RELEASE" == "true" ]; then
if [ "$RESTY_IMAGE_BASE" == "alpine" ]; then
docker tag mashape/kong-build-tools:go-plugin-tool-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG}-${DOCKER_GO_SUFFIX} kong/go-plugin-tool:${KONG_VERSION}-alpine
docker push kong/go-plugin-tool:${KONG_VERSION}-alpine
fi

if [ "$RESTY_IMAGE_TAG" == "bionic" ]; then
docker tag mashape/kong-build-tools:go-plugin-tool-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG}-${DOCKER_GO_SUFFIX} kong/go-plugin-tool:${KONG_VERSION}
docker push kong/go-plugin-tool:${KONG_VERSION}
fi
fi

if [ "$RESTY_IMAGE_BASE" == "ubuntu" ] || [ "$RESTY_IMAGE_BASE" == "debian" ]; then
BINTRAY_DIRECTORY=""
REPOSITORY_TYPE="${REPOSITORY_TYPE:-deb}"
Expand Down
25 changes: 17 additions & 8 deletions test/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ ARG RESTY_IMAGE_BASE="ubuntu"
ARG RESTY_IMAGE_TAG="bionic"
ARG DOCKER_KONG_SUFFIX
ARG DOCKER_OPENRESTY_SUFFIX
ARG DOCKER_GO_SUFFIX
ARG DOCKER_REPOSITORY

FROM ${DOCKER_REPOSITORY}:go-plugin-tool-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG}-${DOCKER_GO_SUFFIX} as GOLANG

FROM ${DOCKER_REPOSITORY}:test-${DOCKER_OPENRESTY_SUFFIX}

ENV PATH=$PATH:/kong/bin:/usr/local/openresty/bin/:/usr/local/kong/bin/:/usr/local/openresty/nginx/sbin/
ENV LUA_PATH=/kong/?.lua;/kong/?/init.lua;/root/.luarocks/share/lua/5.1/?.lua;/root/.luarocks/share/lua/5.1/?/init.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;./?.lua;/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/?.lua;/usr/local/openresty/luajit/share/lua/5.1/?.lua;/usr/local/openresty/luajit/share/lua/5.1/?/init.lua
ENV LUA_CPATH=/root/.luarocks/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/?.so;./?.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so
ENV GO_VERSION="1.13.12"

ARG KONG_GO_PLUGINSERVER_VERSION=master
ENV KONG_GO_PLUGINSERVER_VERSION $KONG_GO_PLUGINSERVER_VERSION

RUN cp -R /tmp/build/* / || true
RUN rm -rf /usr/local/bin/kong
Expand All @@ -28,11 +29,21 @@ RUN ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \
dpkg-reconfigure --frontend noninteractive tzdata && \
apt-get install -y postgresql

COPY --from=GOLANG /usr/local/go /usr/local/go
RUN curl -L https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz \
-o /tmp/go.tar.gz && \
cd /tmp && tar -xf go.tar.gz

ENV KONG_GO_PLUGINSERVER_VERSION=master
ENV GOPATH=/tmp/go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
ENV PATH $GOPATH/bin:$PATH

RUN go version ; \
mkdir /gps ; cd /gps ; \
go mod init go-pluginserver ; \
go get -d -v github.com/Kong/go-pluginserver@${KONG_GO_PLUGINSERVER_VERSION} ; \
go install -ldflags="-s -w -X main.version=${KONG_GO_PLUGINSERVER_VERSION}" ... ; \
cp /tmp/go/bin/go-pluginserver /usr/local/bin/ ;\
cd ; rm -r /gps; \
go-pluginserver --version

RUN rm -rf /kong/* || true
COPY kong /kong
Expand All @@ -47,6 +58,4 @@ RUN curl -L https://cpanmin.us | perl - App::cpanminus \

RUN rm -rf /tmp/build

COPY --from=GOLANG /usr/local/bin/go-pluginserver /usr/local/bin/go-pluginserver

CMD ["sh", "-c", "cat /kong/spec/fixtures/hosts >> /etc/hosts; tail -f /dev/null"]
1 change: 0 additions & 1 deletion test/kong-tests-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ services:
environment:
KONG_ADMIN_ACCESS_LOG: /dev/stdout
KONG_ADMIN_ERROR_LOG: /dev/stderr
KONG_GO_PLUGINS_DIR: "${KONG_GO_PLUGINS_DIR:-off}"
KONG_PLUGINS: "${KONG_PLUGINS:-bundled}"
KONG_CASSANDRA_CONTACT_POINTS: db
KONG_DATABASE: postgres
Expand Down
1 change: 0 additions & 1 deletion test/tests/01-package/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ docker run ${USE_TTY} --user=root --rm ${KONG_TEST_IMAGE_NAME} /bin/sh -c "luaro

# kong binaries
docker run ${USE_TTY} --user=root --rm ${KONG_TEST_IMAGE_NAME} /bin/sh -c "/usr/local/kong/bin/openssl version | grep -q ${RESTY_OPENSSL_VERSION}"
docker run ${USE_TTY} --user=root --rm ${DOCKER_GO_BUILDER} /bin/sh -c "ls -la /usr/local/bin/go-pluginserver"

# TODO enable this test in other distros containing systemd
if [[ "$RESTY_IMAGE_TAG" == "bionic" ]]; then
Expand Down
11 changes: 0 additions & 11 deletions test/tests/03-go-plugins/Dockerfile.custom_kong

This file was deleted.

2 changes: 0 additions & 2 deletions test/tests/03-go-plugins/down.sh

This file was deleted.

17 changes: 0 additions & 17 deletions test/tests/03-go-plugins/run.sh

This file was deleted.

29 changes: 0 additions & 29 deletions test/tests/03-go-plugins/up.sh

This file was deleted.

0 comments on commit ab02bf9

Please sign in to comment.