diff --git a/Makefile b/Makefile index 4a187ea6ee44..ecf579b9b860 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,7 @@ 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} @@ -152,6 +153,23 @@ endif -t $(DOCKER_REPOSITORY):$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_BASE_SUFFIX) . ) -$(UPDATE_CACHE_COMMAND) $(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) \ + --build-arg DEBUG=$(DEBUG) \ + -t $(DOCKER_REPOSITORY):go-plugin-tool-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_GO_SUFFIX) . ) + -$(UPDATE_CACHE_COMMAND) $(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" @@ -235,11 +253,13 @@ 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) . ) -$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):kong-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_KONG_SUFFIX) @@ -253,6 +273,8 @@ 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 @@ -261,6 +283,7 @@ 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) @@ -277,6 +300,7 @@ 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) \ @@ -287,11 +311,13 @@ 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-kong.sh endif @@ -320,7 +346,7 @@ ifneq ($(RESTY_IMAGE_BASE),src) KONG_ADMIN_URI="http://$(TEST_HOST):$(TEST_ADMIN_PORT)" \ KONG_PROXY_URI="http://$(TEST_HOST):$(TEST_PROXY_PORT)" \ TEST_COMPOSE_PATH=$(TEST_COMPOSE_PATH) \ - DOCKER_GO_BUILDER=$(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_OPENRESTY_SUFFIX) \ + DOCKER_GO_BUILDER=$(DOCKER_REPOSITORY):go-plugin-tool-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_GO_SUFFIX) \ ./test/run_tests.sh endif diff --git a/dockerfiles/Dockerfile.golang b/dockerfiles/Dockerfile.golang new file mode 100644 index 000000000000..06541c3be806 --- /dev/null +++ b/dockerfiles/Dockerfile.golang @@ -0,0 +1,54 @@ +ARG RESTY_IMAGE_BASE="ubuntu" +ARG RESTY_IMAGE_TAG="bionic" +ARG DOCKER_BASE_SUFFIX +ARG DOCKER_REPOSITORY + +FROM ${DOCKER_REPOSITORY}:${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG}-${DOCKER_BASE_SUFFIX} + +ENV GOLANG_VERSION 1.13.5 +ARG KONG_GO_PLUGINSERVER_VERSION=master +ENV KONG_GO_PLUGINSERVER_VERSION $KONG_GO_PLUGINSERVER_VERSION + + +RUN set -eux; \ + dpkgArch="$(dpkg --print-architecture || echo amd64)"; \ + case "${dpkgArch##*-}" in \ + amd64) goRelArch='linux-amd64'; goRelSha256='512103d7ad296467814a6e3f635631bd35574cab3369a97a323c9a585ccaa569' ;; \ + armhf) goRelArch='linux-armv6l'; goRelSha256='26259f61d52ee2297b1e8feef3a0fc82144b666a2b95512402c31cc49713c133' ;; \ + arm64) goRelArch='linux-arm64'; goRelSha256='227b718923e20c846460bbecddde9cb86bad73acc5fb6f8e1a96b81b5c84668b' ;; \ + *) goRelArch='src'; goRelSha256='27d356e2a0b30d9983b60a788cf225da5f914066b37a6b4f69d457ba55a626ff'; \ + echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \ + esac; \ + \ + url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ + curl -fsSLo go.tgz "$url"; \ + echo "${goRelSha256} *go.tgz" | sha256sum -c -; \ + tar -C /usr/local -xzf go.tgz; \ + rm go.tgz; \ + \ + if [ "$goRelArch" = 'src' ]; then \ + echo >&2; \ + echo >&2 'error: UNIMPLEMENTED'; \ + echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \ + echo >&2; \ + exit 1; \ + fi; \ + \ + export PATH="/usr/local/go/bin:$PATH" ; \ + export GOPATH="/tmp/go" ; \ + \ + mkdir /gps ; cd /gps ; \ + go mod init go-pluginserver ; \ + go get -d -v github.com/Kong/go-pluginserver@${KONG_GO_PLUGINSERVER_VERSION} ; \ + go install ... ; \ + cp /tmp/go/bin/go-pluginserver /usr/local/bin/ ;\ + cd ; rm -r /gps + +RUN (echo '#!/bin/sh' && echo 'go build -buildmode=plugin "$@"') >> /usr/local/bin/build && \ + chmod a+x /usr/local/bin/build + +ENV GOPATH=/tmp/go +ENV PATH /usr/local/go/bin:$PATH + +VOLUME /plugins +WORKDIR /plugins diff --git a/dockerfiles/Dockerfile.kong b/dockerfiles/Dockerfile.kong index 15b955d43efe..56e687eeac96 100644 --- a/dockerfiles/Dockerfile.kong +++ b/dockerfiles/Dockerfile.kong @@ -1,8 +1,11 @@ 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 @@ -12,3 +15,5 @@ COPY build-kong.sh /build-kong.sh RUN /build-kong.sh COPY kong.logrotate /tmp/build/etc/kong/kong.logrotate + +COPY --from=GOLANG /usr/local/bin/go-pluginserver /tmp/build/usr/local/bin/go-pluginserver diff --git a/dockerfiles/Dockerfile.openresty b/dockerfiles/Dockerfile.openresty index 30fd5dd5f1c3..e1cdb654f4bb 100644 --- a/dockerfiles/Dockerfile.openresty +++ b/dockerfiles/Dockerfile.openresty @@ -65,54 +65,6 @@ RUN if [ "$EDITION" = "enterprise" ] ; then curl -fsSLo /tmp/passwdqc-${KONG_DEP MANDIR=/usr/local/share/man \ install_lib; fi -ENV GOLANG_VERSION 1.13.5 - -RUN set -eux; \ - dpkgArch="$(dpkg --print-architecture || echo amd64)"; \ - case "${dpkgArch##*-}" in \ - amd64) goRelArch='linux-amd64'; goRelSha256='512103d7ad296467814a6e3f635631bd35574cab3369a97a323c9a585ccaa569' ;; \ - armhf) goRelArch='linux-armv6l'; goRelSha256='26259f61d52ee2297b1e8feef3a0fc82144b666a2b95512402c31cc49713c133' ;; \ - arm64) goRelArch='linux-arm64'; goRelSha256='227b718923e20c846460bbecddde9cb86bad73acc5fb6f8e1a96b81b5c84668b' ;; \ - *) goRelArch='src'; goRelSha256='27d356e2a0b30d9983b60a788cf225da5f914066b37a6b4f69d457ba55a626ff'; \ - echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \ - esac; \ - \ - url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \ - curl -fsSLo go.tgz "$url"; \ - echo "${goRelSha256} *go.tgz" | sha256sum -c -; \ - tar -C /usr/local -xzf go.tgz; \ - rm go.tgz; \ - \ - if [ "$goRelArch" = 'src' ]; then \ - echo >&2; \ - echo >&2 'error: UNIMPLEMENTED'; \ - echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \ - echo >&2; \ - exit 1; \ - fi; \ - \ - export PATH="/usr/local/go/bin:$PATH" - - -ARG KONG_GO_PLUGINSERVER_VERSION=master -ENV KONG_GO_PLUGINSERVER_VERSION $KONG_GO_PLUGINSERVER_VERSION - -ENV GOPATH=/tmp/go -ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH - -RUN go version -RUN mkdir -p /tmp/go/src/github.com/kong/ \ - && git clone --branch ${KONG_GO_PLUGINSERVER_VERSION} https://github.com/Kong/go-pluginserver.git /tmp/go/src/github.com/kong/go-pluginserver \ - && cd /tmp/go/src/github.com/kong/go-pluginserver \ - && go mod tidy - -RUN set -eux; \ - dpkgArch="$(dpkg --print-architecture || echo amd64)" \ - && cd /tmp/go/src/github.com/kong/go-pluginserver \ - && make build GOARCH=$dpkgArch GOOS=linux \ - && mkdir -p /tmp/build/usr/local/bin/ \ - && mv go-pluginserver /tmp/build/usr/local/bin/ - ARG RESTY_VERSION=1.13.6.2 LABEL resty_version="${RESTY_VERSION}" diff --git a/release-kong.sh b/release-kong.sh index 23c97a146eaf..d4b707480fd3 100755 --- a/release-kong.sh +++ b/release-kong.sh @@ -22,6 +22,11 @@ if [ "$REPOSITORY_OS_NAME" == "next" ]; then fi if [ "$RESTY_IMAGE_BASE" != "src" ]; 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}-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} + docker push kong/go-plugin-tool:${KONG_VERSION}-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} + docker tag mashape/kong-build-tools:go-plugin-tool-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG}-${DOCKER_GO_SUFFIX} kong/go-plugin-tool:${DOCKER_TAG}-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} + docker push kong/go-plugin-tool:${DOCKER_TAG}-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} + docker tag localhost:5000/kong-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} ${DOCKER_REPOSITORY}:${KONG_VERSION}-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} docker push ${DOCKER_REPOSITORY}:${KONG_VERSION}-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} docker tag localhost:5000/kong-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} ${DOCKER_REPOSITORY}:${DOCKER_TAG}-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} @@ -56,6 +61,7 @@ elif [ "$RESTY_IMAGE_BASE" == "alpine" ]; then docker tag localhost:5000/kong-${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG} ${DOCKER_REPOSITORY}:${DOCKER_TAG} docker push ${DOCKER_REPOSITORY}:${DOCKER_TAG} + elif [ "$RESTY_IMAGE_BASE" == "amazonlinux" ]; then BINTRAY_DIRECTORY="amazonlinux/amazonlinux" REPOSITORY_TYPE="${REPOSITORY_TYPE:-rpm}" @@ -209,4 +215,4 @@ print_result "$REPOSITORY_NAME artifact upload" "$RESPONSE" echo -e "\nVersion $KONG_VERSION release finished" -exit 0 \ No newline at end of file +exit 0 diff --git a/test/Dockerfile.test b/test/Dockerfile.test index 75af3f4a311f..596b2e3509c3 100644 --- a/test/Dockerfile.test +++ b/test/Dockerfile.test @@ -1,47 +1,51 @@ -ARG DOCKER_OPENRESTY_SUFFIX -ARG DOCKER_REPOSITORY - -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 - -RUN cp -R /tmp/build/* / || true -RUN rm -rf /usr/local/bin/kong -RUN ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \ - apt-get update && apt-get install -y \ - tzdata \ - vim \ - jq \ - httpie \ - iputils-ping \ - net-tools \ - valgrind \ - net-tools && \ - dpkg-reconfigure --frontend noninteractive tzdata && \ - apt-get install -y postgresql - -ENV KONG_GO_PLUGINSERVER_VERSION=master -ENV GOPATH=/tmp/go -ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH - -RUN rm -rf /tmp/go/src/github.com/kong/ \ - && mkdir -p /tmp/go/src/github.com/kong/ \ - && git clone --branch ${KONG_GO_PLUGINSERVER_VERSION} https://github.com/Kong/go-pluginserver.git /tmp/go/src/github.com/kong/go-pluginserver \ - && cd /tmp/go/src/github.com/kong/go-pluginserver \ - && go mod tidy - -COPY kong /kong -RUN mkdir -p /kong/servroot/logs -RUN chmod -R 777 /kong -WORKDIR /kong -RUN make dev - -RUN curl -L https://cpanmin.us | perl - App::cpanminus \ - && cpanm --notest Test::Nginx \ - && cpanm --notest local::lib - -RUN rm -rf /tmp/build - -CMD ["sh", "-c", "cat /kong/spec/fixtures/hosts >> /etc/hosts; tail -f /dev/null"] +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 + +RUN cp -R /tmp/build/* / || true +RUN rm -rf /usr/local/bin/kong +RUN ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \ + apt-get update && apt-get install -y \ + tzdata \ + vim \ + jq \ + httpie \ + iputils-ping \ + net-tools \ + valgrind \ + net-tools && \ + dpkg-reconfigure --frontend noninteractive tzdata && \ + apt-get install -y postgresql + +COPY --from=GOLANG /usr/local/go /usr/local/go + +ENV KONG_GO_PLUGINSERVER_VERSION=master +ENV GOPATH=/tmp/go +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH + +COPY kong /kong +RUN mkdir -p /kong/servroot/logs +RUN chmod -R 777 /kong +WORKDIR /kong +RUN make dev + +RUN curl -L https://cpanmin.us | perl - App::cpanminus \ + && cpanm --notest Test::Nginx \ + && cpanm --notest local::lib + +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"] diff --git a/test/tests/01-package/run.sh b/test/tests/01-package/run.sh index b40dfba19c0d..eabef314b645 100644 --- a/test/tests/01-package/run.sh +++ b/test/tests/01-package/run.sh @@ -15,7 +15,7 @@ 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 ${KONG_TEST_IMAGE_NAME} /bin/sh -c "ls -la /usr/local/bin/go-pluginserver" +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 diff --git a/test/tests/03-go-plugins/Dockerfile.custom_kong b/test/tests/03-go-plugins/Dockerfile.custom_kong index 70eb812785a0..8073fbfe0d74 100644 --- a/test/tests/03-go-plugins/Dockerfile.custom_kong +++ b/test/tests/03-go-plugins/Dockerfile.custom_kong @@ -4,7 +4,7 @@ FROM ${KONG_TEST_IMAGE_NAME} USER root -COPY go-hello.so /usr/local/kong +COPY go-plugins/*.so /usr/local/kong/ RUN chown -R kong:0 /usr/local/kong diff --git a/test/tests/03-go-plugins/up.sh b/test/tests/03-go-plugins/up.sh index 742d93951828..73b89960ab20 100644 --- a/test/tests/03-go-plugins/up.sh +++ b/test/tests/03-go-plugins/up.sh @@ -1,22 +1,35 @@ # clone plugins git clone https://github.com/Kong/go-plugins +pushd go-plugins -echo $DOCKER_GO_BUILDER -docker build --build-arg DOCKER_GO_BUILDER=$DOCKER_GO_BUILDER \ - -f Dockerfile.build_plugin -t go-plugin-builder . -docker run --name go-plugin-builder-container go-plugin-builder + echo "Go builder image: $DOCKER_GO_BUILDER" -docker cp go-plugin-builder-container:/go-plugins/go-hello.so . + for src in *.go; do + echo "compile $src" + docker run --rm -v $(pwd):/plugins $DOCKER_GO_BUILDER build $src + done -docker rm -f go-plugin-builder-container -rm -rf go-plugins +popd + +# cp -v *.so /usr/local/kong +# cd .. +# rm -rf go-plugins + +# docker build --build-arg DOCKER_GO_BUILDER=$DOCKER_GO_BUILDER \ +# -f Dockerfile.build_plugin -t go-plugin-builder . +# docker run --name go-plugin-builder-container go-plugin-builder + +# docker cp go-plugin-builder-container:/go-plugins/go-hello.so . + +# docker rm -f go-plugin-builder-container +# rm -rf go-plugins echo $KONG_TEST_IMAGE_NAME docker build --build-arg KONG_TEST_IMAGE_NAME=$KONG_TEST_IMAGE_NAME \ -f Dockerfile.custom_kong -t custom-kong-with-go-plugin . -rm -f go-hello.so +rm -rf go-plugins KONG_PLUGINS=go-hello KONG_GO_PLUGINS_DIR=/usr/local/kong start_kong custom-kong-with-go-plugin wait_kong