github.com/craicoverflow/tyk@v2.9.6-rc3+incompatible/images/plugin-compiler/data/build.sh (about) 1 #!/bin/bash 2 3 set -xe 4 5 plugin_name=$1 6 plugin_path=$(date +%s)-$plugin_name 7 8 function usage() { 9 cat <<EOF 10 To build a plugin: 11 $0 <plugin_name> 12 13 EOF 14 } 15 16 if [ -z "$plugin_name" ]; then 17 usage 18 exit 1 19 fi 20 21 # Handle if plugin has own vendor folder, and ignore error if not 22 yes | cp -r $PLUGIN_SOURCE_PATH/* $PLUGIN_BUILD_PATH || true 23 yes | cp -r $PLUGIN_BUILD_PATH/vendor $GOPATH/src || true \ 24 && rm -rf $PLUGIN_BUILD_PATH/vendor 25 26 cd $PLUGIN_BUILD_PATH \ 27 && go build -buildmode=plugin -ldflags "-pluginpath=$plugin_path" -o $plugin_name \ 28 && mv $plugin_name $PLUGIN_SOURCE_PATH