-
Notifications
You must be signed in to change notification settings - Fork 72
/
build-kong.sh
executable file
·89 lines (71 loc) · 3.11 KB
/
build-kong.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
set -e
source /common.sh
ROCKS_CONFIG=$(mktemp)
echo "
rocks_trees = {
{ name = [[system]], root = [[/tmp/build/usr/local]] }
}
" > $ROCKS_CONFIG
if [[ -d /usr/local/share/lua ]]; then
cp -R /usr/local/share/lua/ /tmp/build/usr/local/share/
fi
cp -R /tmp/build/* /
export LUAROCKS_CONFIG=$ROCKS_CONFIG
export LUA_PATH="/usr/local/share/lua/5.1/?.lua;/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/?.lua;;"
export PATH=$PATH:/usr/local/openresty/luajit/bin
/usr/local/bin/luarocks --version
/usr/local/kong/bin/openssl version || true
ldd /usr/local/openresty/nginx/sbin/nginx || true
strings /usr/local/openresty/nginx/sbin/nginx | grep rpath || true
strings /usr/local/openresty/bin/openresty | grep rpath || true
find /usr/local/kong/lib/ || true
/usr/local/openresty/bin/openresty -V || true
pushd /kong
ROCKSPEC_VERSION=`basename /kong/kong-*.rockspec` \
&& ROCKSPEC_VERSION=${ROCKSPEC_VERSION%.*} \
&& ROCKSPEC_VERSION=${ROCKSPEC_VERSION#"kong-"}
mkdir -p /tmp/plugin
if [ "$SSL_PROVIDER" = "boringssl" ]; then
sed -i 's/fips = off/fips = on/g' kong/templates/kong_defaults.lua
fi
with_backoff /usr/local/bin/luarocks make kong-${ROCKSPEC_VERSION}.rockspec \
CRYPTO_DIR=/usr/local/kong \
OPENSSL_DIR=/usr/local/kong \
YAML_LIBDIR=/tmp/build/usr/local/kong/lib \
YAML_INCDIR=/tmp/yaml \
EXPAT_DIR=/usr/local/kong \
LIBXML2_DIR=/usr/local/kong \
CFLAGS="-L/tmp/build/usr/local/kong/lib -Wl,-rpath,/usr/local/kong/lib -O2 -std=gnu99 -fPIC"
mkdir -p /tmp/build/etc/kong
cp kong.conf.default /tmp/build/usr/local/lib/luarocks/rock*/kong/$ROCKSPEC_VERSION/
cp kong.conf.default /tmp/build/etc/kong/kong.conf.default
# /usr/local/kong/include is usually created by other C libraries, like openssl
# call mkdir here to make sure it's created
if [ -e "kong/include" ]; then
mkdir -p /tmp/build/usr/local/kong/include
cp -r kong/include/* /tmp/build/usr/local/kong/include/
fi
# circular dependency of CI: remove after https://github.com/Kong/kong-distributions/pull/791 is merged
if [ -e "kong/pluginsocket.proto" ]; then
cp kong/pluginsocket.proto /tmp/build/usr/local/kong/include/kong
fi
with_backoff curl -fsSLo /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.19.0/protoc-3.19.0-linux-x86_64.zip
unzip -o /tmp/protoc.zip -d /tmp/protoc 'include/*'
cp -r /tmp/protoc/include/google /tmp/build/usr/local/kong/include/
popd
cp /kong/COPYRIGHT /tmp/build/usr/local/kong/
cp /kong/bin/kong /tmp/build/usr/local/bin/kong
sed -i 's/resty/\/usr\/local\/openresty\/bin\/resty/' /tmp/build/usr/local/bin/kong
sed -i 's/\/tmp\/build//g' /tmp/build/usr/local/bin/openapi2kong || true
grep -l -I -r '\/tmp\/build' /tmp/build/
sed -i 's/\/tmp\/build//' `grep -l -I -r '\/tmp\/build' /tmp/build/`
chown -R 1000:1000 /tmp/build/*
# bytecompile if script is present (as with ee)
if test -f "/distribution/post-bytecompile.sh"; then
/distribution/post-bytecompile.sh
fi
# add copyright manifests if script is present (as with ee)
if test -f "/distribution/post-copyright-manifests.sh"; then
/distribution/post-copyright-manifests.sh
fi