Skip to content

Commit

Permalink
Abandoning tyk-build-env, images will live in their respective repos
Browse files Browse the repository at this point in the history
  • Loading branch information
alephnull committed Sep 23, 2019
1 parent 6418fcb commit 2f2973a
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 0 deletions.
50 changes: 50 additions & 0 deletions images/README.md
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.
27 changes: 27 additions & 0 deletions images/build-env/Dockerfile
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 added images/build-env/OpenSSL_1_0_2o.tar.gz
Binary file not shown.
Binary file added images/build-env/Python-3.4.10.tgz
Binary file not shown.
1 change: 1 addition & 0 deletions images/build-env/openssl1.0.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/usr/local/ssl/lib
17 changes: 17 additions & 0 deletions images/plugin-compiler/Dockerfile
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"]

32 changes: 32 additions & 0 deletions images/plugin-compiler/data/build.sh
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

0 comments on commit 2f2973a

Please sign in to comment.