Skip to content

Instantly share code, notes, and snippets.

@bunchc
Last active May 12, 2023 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bunchc/51cb11b968c6f6fe6ec8b54415360668 to your computer and use it in GitHub Desktop.
Save bunchc/51cb11b968c6f6fe6ec8b54415360668 to your computer and use it in GitHub Desktop.
Using custom golang plugins with the Kong Ubuntu image
# To build and load custom GO plugins into the Kong Ubuntu image
# we use a multistage docker build. The first stage uses the golang
# image to build the plugin. The second stage then copies that plugin
# into the Kong Ubuntu image.
# Build the golang plugin
FROM golang:alpine as build
WORKDIR /plugin
COPY go-plugins/* ./
RUN go build go-hello.go
# Copy the plugin into the kong-gateway image as root:
# ref: https://docs.konghq.com/gateway/latest/plugin-development/pluginserver/plugins-kubernetes/
FROM kong/kong-gateway:3.2.2.1-ubuntu
USER root
COPY --from=build /plugin/go-hello /usr/local/bin/go-hello
# Return the image to defaults for runtime
USER kong
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 8000 8443 8001 8444
STOPSIGNAL SIGQUIT
HEALTHCHECK --interval=10s --timeout=10s --retries=10 CMD kong health
CMD ["kong", "docker-start"]
# To build and load custom GO plugins into the Kong Ubuntu image
# we use a multistage docker build. The first stage uses the golang
# image to build the plugin. The second stage then copies that plugin
# into the Kong Ubuntu image.
# Build the golang plugin
FROM --platform=linux/amd64 golang:alpine as build
WORKDIR /plugin
COPY go-plugins/* ./
RUN go build go-hello.go
# Copy the plugin into the kong-gateway image as root:
# ref: https://docs.konghq.com/gateway/latest/plugin-development/pluginserver/plugins-kubernetes/
FROM --platform=linux/amd64 kong/kong-gateway:3.2.2.1-ubuntu
USER root
COPY --from=build /plugin/go-hello /usr/local/bin/go-hello
# Return the image to defaults for runtime
USER kong
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 8000 8443 8001 8444
STOPSIGNAL SIGQUIT
HEALTHCHECK --interval=10s --timeout=10s --retries=10 CMD kong health
CMD ["kong", "docker-start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment