diff --git a/Makefile b/Makefile index 67b8dc6b..8d9c7407 100644 --- a/Makefile +++ b/Makefile @@ -247,16 +247,23 @@ actual-build-kong: kong-test-container: ifneq ($(RESTY_IMAGE_BASE),src) - $(CACHE_COMMAND) $(DOCKER_REPOSITORY):test-$(DOCKER_TEST_SUFFIX) || \ - ( $(MAKE) build-kong && $(DOCKER_COMMAND) -f test/Dockerfile.test \ + -rm -rf kong + -cp -R $(KONG_SOURCE_LOCATION) kong + + $(CACHE_COMMAND) $(DOCKER_REPOSITORY):test-$(DOCKER_OPENRESTY_SUFFIX) || \ + ( $(MAKE) build-openresty && \ + docker tag $(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(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) \ - --build-arg DOCKER_KONG_SUFFIX=$(DOCKER_KONG_SUFFIX) \ - --build-arg DOCKER_BASE_SUFFIX=$(DOCKER_BASE_SUFFIX) \ --build-arg DOCKER_REPOSITORY=$(DOCKER_REPOSITORY) \ - --build-arg KONG_SHA=${KONG_SHA} \ - -t $(DOCKER_REPOSITORY):test-$(DOCKER_TEST_SUFFIX) . ) - -$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):test-$(DOCKER_TEST_SUFFIX) + --build-arg DOCKER_OPENRESTY_SUFFIX=$(DOCKER_OPENRESTY_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_REPOSITORY):test-$(DOCKER_OPENRESTY_SUFFIX) + -$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):test-$(DOCKER_OPENRESTY_SUFFIX) endif test-kong: kong-test-container diff --git a/dockerfiles/Dockerfile.openresty b/dockerfiles/Dockerfile.openresty index e6e93027..30fd5dd5 100644 --- a/dockerfiles/Dockerfile.openresty +++ b/dockerfiles/Dockerfile.openresty @@ -141,7 +141,6 @@ RUN DEBUG="${DEBUG}" /tmp/build-openresty.sh \ WORKDIR /kong COPY kong /kong -COPY id_rsa /root/id_rsa COPY build-kong.sh /build-kong.sh RUN /build-kong.sh && rm -rf /kong diff --git a/test/Dockerfile.test b/test/Dockerfile.test index 28887e84..75af3f4a 100644 --- a/test/Dockerfile.test +++ b/test/Dockerfile.test @@ -1,56 +1,47 @@ -ARG RESTY_IMAGE_BASE="ubuntu" -ARG RESTY_IMAGE_TAG="bionic" -ARG DOCKER_KONG_SUFFIX -ARG DOCKER_BASE_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}:${RESTY_IMAGE_BASE}-${RESTY_IMAGE_TAG}-${DOCKER_BASE_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 - -COPY --from=KONG /tmp/build/ /tmp/build -RUN cp -R /tmp/build/* / -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=KONG /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 - -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 - - -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 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"]