-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abandoning tyk-build-env, images will live in their respective repos
- Loading branch information
Showing
7 changed files
with
127 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# build-env | ||
|
||
Docker environment used to build official images and plugins. | ||
|
||
This is the base image that will slowly be used in all our builds. It | ||
is not capable of handling i386 or arm64 builds. Those builds are | ||
handled by installing additional components in the environment section | ||
of the pipeline. | ||
|
||
This image will need to be updated only when upgrading the go version | ||
or if some system dependencies for building change. This image is | ||
mainly used internally at Tyk for CD pipelines. | ||
|
||
# plugin-compiler | ||
|
||
The usecase is that you have a plugin (probably Go) that you require | ||
to be built. | ||
|
||
Navigate to where your plugin is and build using a docker volume to | ||
mount your code into the image. Since the vendor directory needs to be | ||
identical between the gateway build and the plugin build, this means | ||
that you should pull the version of this image corresponding to the | ||
gateway version you are using. | ||
|
||
This also implies that if your plugin has vendored modules that are | ||
[also used by Tyk | ||
gateway](https://github.com/TykTechnologies/tyk/tree/master/vendor) | ||
then your module will be overridden by the version that Tyk uses. | ||
|
||
``` shell | ||
cd ${GOPATH}/src/tyk-plugin | ||
docker run -v `pwd`:/go/src/plugin-build plugin-build pre | ||
``` | ||
|
||
You will find a `pre.so` in the current directory which is the file | ||
that goes into the API definition | ||
|
||
## Building the image | ||
|
||
This will build the image that will be used in the plugin build | ||
step. This section is for only for informational purposes. | ||
|
||
In the root of the repo: | ||
|
||
``` shell | ||
docker build --build-arg TYK_GW_TAG=v2.8.4 -t tyk-plugin-build-2.8.4 . | ||
``` | ||
|
||
TYK_GW_TAG refers to the _tag_ in github corresponding to a released | ||
version. |
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,27 @@ | ||
FROM golang:1.12 | ||
LABEL io.tyk.vendor="Tyk" \ | ||
version="1.0" \ | ||
description="Base image for builds" | ||
|
||
ENV GOPATH=/ | ||
|
||
RUN apt-get update && apt-get dist-upgrade -y && \ | ||
apt-get install -y ca-certificates \ | ||
git \ | ||
locales \ | ||
curl \ | ||
jq \ | ||
rpm \ | ||
build-essential \ | ||
libluajit-5.1-2 \ | ||
libluajit-5.1-dev \ | ||
luarocks \ | ||
python3-setuptools \ | ||
python3-dev \ | ||
python3-pip \ | ||
ruby-dev | ||
RUN luarocks install lua-cjson | ||
RUN pip3 install grpcio protobuf | ||
RUN mkdir -p $GOPATH ~/rpmbuild/SOURCES ~/rpmbuild/SPECS | ||
RUN go get github.com/mitchellh/gox | ||
RUN gem install fpm rake package_cloud |
Binary file not shown.
Binary file not shown.
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 @@ | ||
/usr/local/ssl/lib |
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,17 @@ | ||
FROM tykio/tyk-build-env:latest | ||
LABEL io.tyk.vendor="Tyk" \ | ||
version="1.0" \ | ||
description="Image for plugin development" | ||
|
||
ARG TYK_GW_TAG | ||
ENV TYK_GW_PATH=${GOPATH}/src/github.com/TykTechnologies/tyk | ||
|
||
RUN mkdir -p /go/src/plugin-build $TYK_GW_PATH | ||
COPY data/build.sh /build.sh | ||
RUN chmod +x /build.sh | ||
|
||
RUN curl -sL "https://api.github.com/repos/TykTechnologies/tyk/tarball/${TYK_GW_TAG}" | \ | ||
tar -C $TYK_GW_PATH --strip-components=1 -xzf - | ||
|
||
ENTRYPOINT ["/build.sh"] | ||
|
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,32 @@ | ||
#!/bin/bash | ||
|
||
set -xe | ||
# This directory will contain the plugin source and will be | ||
# mounted from the host box by the user using docker volumes | ||
PLUGIN_BUILD_PATH=/go/src/plugin-build | ||
|
||
plugin_name=$1 | ||
|
||
function usage() { | ||
cat <<EOF | ||
To build a plugin: | ||
$0 <plugin_name> | ||
EOF | ||
} | ||
|
||
if [ -z "$plugin_name" ]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
# Handle if plugin has own vendor folder, and ignore error if not | ||
yes | cp -r $PLUGIN_BUILD_PATH/vendor $GOPATH/src || true | ||
rm -rf $PLUGIN_BUILD_PATH/vendor | ||
|
||
# Move GW vendor folder to GOPATH (same step should be made during building main binaries) | ||
yes | cp -r $TYK_GW_PATH/vendor $GOPATH/src | ||
rm -rf $TYK_GW_PATH/vendor | ||
|
||
cd $PLUGIN_BUILD_PATH && \ | ||
go build -buildmode=plugin -o $plugin_name |