-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
77 lines (58 loc) · 3.15 KB
/
Dockerfile
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
ARG KONG_IMAGE_NAME
ARG KONG_IMAGE_TAG
FROM ${KONG_IMAGE_NAME}:${KONG_IMAGE_TAG} AS builder
USER root
# The arg/env variable is already defined in the base image. Due to a buildah bug
# the variable KONG_VERSION can't be used and will always be an empty string.
ARG KONG_TARGET_VERSION
ARG KONG_PLUGIN_NAME
ARG PONGO_KONG_VERSION
ARG PONGO_ARCHIVE
ARG STYLUA_VERSION
ARG EMMY_LUA_DEBUGGER_VERSION
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN dnf install -y cmake gcc m4 git --setopt=install_weak_deps=False \
&& curl -sSf -L https://github.com/Kong/kong-pongo/archive/refs/heads/master.tar.gz | tar xfvz - -C / --strip-components 3 kong-pongo-master/kong-versions/"${PONGO_KONG_VERSION}" \
&& echo 'database = off' >> /kong/spec/kong_tests.conf \
# Install stylua
&& curl -sSf -L "https://github.com/JohnnyMorganz/StyLua/releases/download/v${STYLUA_VERSION}/stylua-linux-x86_64.zip" -o /tmp/stylua-linux-x86_64.zip \
# Download and compile EmmyLuaDebugger
&& curl -sSf -L "https://github.com/EmmyLua/EmmyLuaDebugger/archive/refs/tags/${EMMY_LUA_DEBUGGER_VERSION}.zip" -o /tmp/emmylua-debugger.zip \
&& unzip /tmp/emmylua-debugger.zip -d /tmp \
&& mkdir /tmp/EmmyLuaDebugger-${EMMY_LUA_DEBUGGER_VERSION}/build \
&& cd /tmp/EmmyLuaDebugger-${EMMY_LUA_DEBUGGER_VERSION}/build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DEMMY_CORE_VERSION=${EMMY_LUA_DEBUGGER_VERSION} \
&& cmake --build . --config Release \
&& unzip /tmp/stylua-linux-x86_64.zip -d /usr/local/bin \
&& cp /tmp/EmmyLuaDebugger-${EMMY_LUA_DEBUGGER_VERSION}/build/emmy_core/emmy_core.so /usr/local/lib/lua/5.1 \
&& rm -rf /var/tmp/*
COPY _build/images/kong-plugin-testing-0.1.0-0.rockspec /kong-plugin-testing-0.1.0-0.rockspec
# Install package dependencies used for unit and integration tests.
RUN luarocks build /kong-plugin-testing-0.1.0-0.rockspec --only-deps OPENSSL_DIR=/usr/local/kong CRYPTO_DIR=/usr/local/kong
COPY kong-plugin-${KONG_PLUGIN_NAME}-dev-0.rockspec /kong-plugin-${KONG_PLUGIN_NAME}-dev-0.rockspec
# Install package dependencies defined in the plugin rockspec file.
RUN luarocks build /kong-plugin-${KONG_PLUGIN_NAME}-dev-0.rockspec --only-deps OPENSSL_DIR=/usr/local/kong CRYPTO_DIR=/usr/local/kong
FROM ${KONG_IMAGE_NAME}:${KONG_IMAGE_TAG}
ENV LUA_PATH="/kong-plugin/?.lua;/kong-plugin/?/init.lua;;"
ENV KONG_LOG_LEVEL=debug
ENV KONG_PREFIX=/kong-plugin/servroot
ENV KONG_TEST_PREFIX=/kong-plugin/servroot
ENV PATH="/kong/bin:${PATH}"
COPY --from=builder /etc/yum.repos.d/ubi.repo /etc/yum.repos.d/ubi.repo
USER root
# Install hostname and netstat for kong spec testing helper
RUN dnf install -y net-tools hostname --setopt=install_weak_deps=False \
&& dnf clean all \
&& rm -rf /var/cache/dnf
USER kong
# Add the Kong spec installation
COPY --from=builder /kong /kong
# Add binaries from luarocks installation
COPY --from=builder /usr/local/bin /usr/local/bin
# Add the Lua files (.lua)
COPY --from=builder /usr/local/share/lua/5.1 /usr/local/share/lua/5.1
# Add the compiled libraries (.so)
COPY --from=builder /usr/local/lib/lua/5.1 /usr/local/lib/lua/5.1
# Add the Luarocks manifest
COPY --from=builder /usr/local/lib/luarocks/rocks-5.1 /usr/local/lib/luarocks/rocks-5.1
WORKDIR /kong