-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(go) build and push a go-lang docker image for building go-plugins
* split all golang into a separate image there's no golang in the 'openresty' image. the final 'kong' image pulls only the go-pluginserver executable from the golang image. the tests use the golang image to compile go plugins, just as the end user would. * rename image to go-plugin-tool and use DOCKER_GO_SUFFIX key * release: push new docker image * chore(release) send the DOCKER_GO_SUFFIX environment variable to the release script * chore(release) use the latest and dev convenience tags * chrore(release) don't obscure the alpine tag Co-authored-by: Colin Hutchinson <chutchic@gmail.com>
- Loading branch information
1 parent
aadb6bc
commit ea250c3
Showing
9 changed files
with
167 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.